We’re preparing your current view and syncing the latest data.
Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inclusive.
Example: Input: nums = [-2,5,-1], lower = -2, upper = 2 Output: 3 Explanation: The three ranges are:
The input consists of an integer array nums and two integers lower and upper.
Return an integer representing the count of the range sums in [lower, upper].
1 <= nums.length <= 10^5 -2^31 <= nums[i] <= 2^31 - 1 -10^9 <= lower <= upper <= 10^9
Example 1
Input
nums = [-2,5,-1], lower = -2, upper = 2
Output
3
Explanation
The three valid ranges are: [0,0], sum=-2; [2,2], sum=-1; [0,2], sum=2