Given a static array nums, return the sum of values for every queried interval. This is a basic range-query problem that can be solved with a prefix array, but it also serves as a clean introductory case for range-query data structures such as segment trees.
nums = static integer array, queries = range sum requests
sum for each query, in order
Example 1:
Input:
nums = [1,3,5,7] queries = [[0,1],[1,3]]
Output:
[4,15]
Explanation:
The first interval sums to 4 and the second interval sums to 15.
Example 2:
Input:
nums = [2,4,6] queries = [[0,2]]
Output:
[12]
Explanation:
The sum of the full array is 12.