Sum Between Range
Easy
Given an integer array, write a function which returns the sum of values between two indexes.
Example:
Input: nums = [3, -7, 6, 0, -2, 5],
[sum_range(0, 3), sum_range(2, 4), sum_range(2, 2)]
Output: [2, 4, 6]
Constraints:
-
numscontains at least one element. -
Each
sum_rangeoperation will query a valid range of the input array.