Problem statement
You are given an array that never changes, and many questions of the form: what is the sum of the values from position l to position r? Answer them all quickly, with a short fixed amount of work per question, no matter how long the range is.
Examples
Inputa = [1, 2, 3, -2, 5], query l = 1, r = 3
Output3
2 + 3 + (-2) = 3.
Inputa = [1, 2, 3, -2, 5], query l = 0, r = 4
Output9
The whole array sums to 9.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing