Which two boundaries answer a query?
Meter changes are [3,-5,4]. The totals at the four gaps are [0,3,-2,2].
For the inclusive query [1,2], mark the gaps before and after the requested readings.
1 / 6
Meter changes are [3,-5,4]. The totals at the four gaps are [0,3,-2,2].
For the inclusive query [1,2], mark the gaps before and after the requested readings.
Keep one copy in sorted [1,1,4,4,7]. You have read the first two values and accepted one. The next value is 4.
Where can you write it? What will the caller inspect at the end?
On paper, cross out the punctuation in "7,É!é7". Then trace what two indices would do on the original sequence of code points.
Target 8, positive values [2,3,8]. Immediately after the 8 enters, the sum is 13.
Write the length and sum before each removal. What does a single removal miss?
Run the same minimum-window scan on [3,-4,8] with target 8. List the three running sums.
Would a prefix table still answer a query for the last value?
One caller requests every inclusive prefix of a fixed array of length n. A second caller asks for one shortest qualifying window of positive values.
How much work does repeated direct summation do for the first caller? How often can one value enter and leave the second caller's running window?