Your question is Prefix Sum for Range/Subarray. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Supermicro monitoring software stores integer telemetry readings in chronological order. Given the readings and many inclusive range queries, return the sum of each requested range efficiently.
Build a prefix-sum array so that each query can be answered without scanning every element in its range.
Implement range_sum_queries(nums, queries).
nums is a list of integers, where nums[i] is the reading at index i.queries is a list of two-element lists [left, right] with inclusive, zero-based bounds.k is the sum of nums[left:right + 1] for queries[k].def range_sum_queries(nums, queries):