Prefix Sums

Unit 5 of 15

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

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