Concept
A prefix sum array stores the running total up to each index, so the sum of any range is one subtraction. Build it once in O(n) and answer range queries in O(1).
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Prefix sums doing its job.
nums = [3, 1, 4, 1, 5, 9]
prefix = [0]
for n in nums:
prefix.append(prefix[-1] + n)
def range_sum(i, j): # sum of nums[i..j] inclusive
return prefix[j + 1] - prefix[i]
range_sum(1, 3) # 1 + 4 + 1 = 6Off-by-one errors from starting the prefix array at the first element instead of 0. Starting with a leading 0 makes every range formula prefix[j+1] - prefix[i], with no special case for i = 0.
Your roadmap puts these before Prefix sums, unless you already know them.
Once a session shows you understand Prefix sums, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.