Prefix Sums in Python - Range sum queries

This video shows you how to use prefix sums to find the sum of the numbers in a range of a list of numbers in Python 3. The time complexity to generate the prefix sum array is O(n), and the time complexity to then find the sum of the numbers in any range is O(1). This is a more efficient approach than the traditional linear scanning approach, which would have a runtime of O(n * m) for m queries (each query asking for the sum of the numbers in a given range). Be sure to like, comment, and subscribe! 0:00 Explaining prefix sums 6:37 Implementing the prefix sum algorithm 8:21 Testing the algorithm