Foundations
Prefix Sums
Precompute running totals once, then answer any range sum in O(1). Pair them with a hash map to count subarrays, extend them to 2D grids, and run them in reverse as difference arrays.
0 of 3 lessons complete, 0 of 7 problems solved
Coursework
35 min
Up next
Running Totals and Range Sums
Build a prefix array once and answer every range sum with one subtraction.
10 min
Prefix Sum + Hash Map
Count or measure subarrays with a target sum in one pass, even with negative numbers.
13 min
2D Prefix Sums and Difference Arrays
Rectangle sums in O(1), and many range updates in O(1) each.
12 min
Practice ladder
Start with the first problem, then work toward the harder variations. Run examples before submitting against all tests.
Next unit: Stacks & Monotonic Stacks