Subarray sum in range

Write codeHard45 min

Your task

Given an integer array nums and two integers lower and upper, count the number of contiguous subarrays whose sum lies in the inclusive range [lower, upper]. The array may contain negatives and zeros and can be empty. Return the count.

Examples

count_range_sum(nums: list[int], lower: int, upper: int) -> int
Example 1
Inputcount_range_sum([-2, 5, -1], -2, 2)
Output3