Description
Given an integer array nums, handle multiple queries sumRange(left, right) which returns the sum of elements between indices left and right inclusive.
Examples
Input:
nums = [-2, 0, 3, -5, 2, -1], sumRange(0, 2)Output:
1Explanation:
Sum of [-2, 0, 3] = 1.
Input:
nums = [-2, 0, 3, -5, 2, -1], arg2 = 0, arg3 = 2Output:
1Explanation:
Sum of elements from index 0 to 2: -2 + 0 + 3 = 1.
Input:
nums = [-2, 0, 3, -5, 2, -1], arg2 = 2, arg3 = 5Output:
-1Explanation:
Sum of elements from index 2 to 5: 3 + (-5) + 2 + (-1) = -1.
Constraints
- •
1 ≤ nums.length ≤ 10⁴ - •
-10⁵ ≤ nums[i] ≤ 10⁵