Subarray sum in range
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) -> intExample 1
Input
count_range_sum([-2, 5, -1], -2, 2)Output
3