⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 11s17 days 22 hours 20 minutes 11 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 11s17 days 22 hours 20 minutes 11 seconds.

Sign in to watch this lesson
Algorithms - Arrays · 4:17
Running totals drawn as a staircase: with P[0] = 0 and P[i] = P[i-1] + a[i-1], the sum of any half-open range [l, r) is the difference of two heights, P[r] - P[l], in constant time after one linear pass. We race 100,000 range queries on a Mac (a naive loop doing 3.3 billion additions versus prefix sums), answer queries given as timestamps with lower_bound and upper_bound, extend the idea to XOR and counts, see why minimum breaks it, and catch the int overflow that a prefix array invites.