5 hands-on exercises and 5 find-the-bug challenges for the Prefix Sums and Range Queries lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Build running totals with a leading zero and join them.
Use prefix sums to total indices two through five.
Show the total of every value using the prefix array.
Count runs adding to seven using a hash map.
Report the structure needed when values change between queries.
Starting at the first value makes every range need a special case.
The range sum subtracts the prefix before the start, not at it.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceWithout seeding zero, runs starting at index zero are never counted.
Storing before looking up lets a run match itself when the target is zero.
One change invalidates every later entry, so a tree is needed.