Question
An energy meter records one integer watt-hour value per hour, indexed from 0. An analyst submits a batch of queries, each a pair [l, r] with 0 <= l <= r < number of readings, asking for the total consumption from hour l through hour r inclusive. Return the answers in query order. The batch can be large, so each query should be answered in constant time after one preprocessing pass. Example: readings = [3, 1, 4, 1, 5], queries = [[1, 3], [0, 0]] gives [6, 3].
consumption_totals(readings: list[int], queries: list[list[int]]) → list[int][[3,1,4,1,5],[[1,3],[0,0]]]out[6,3]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.