Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopprefix-sums
The organizer’s problem statement is available at the official source link.
sample trace
Moortal Cowmbat: prefix sums walkthrough
Moortal Cowmbat: use the linked editorial?s prefix sums idea on the published sample, then verify the displayed output.
Published input5 5 2
abcde
0 1 4 4 4
2 0 4 4 4
6 5 0 3 2
5 5 5 0 4
3 7 0 5 0modelAlgorithm ideaStore cumulative aggregates so a range can be answered from two prefix values instead of rescanning its elements.task resultExpected output5
- 1
Accumulate
Build the running total or count across the input order. - 2
Query
Subtract the prefix before a range from the prefix at its end. - 3
Finish
Apply the task?s boundary adjustment and compare with the sample result. - 4
Verify the sample
Use the published sample output to check the result of this idea on the displayed input.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.