You're given an integer array nums and two integers l and r. Your task is to find the minimum positive sum among all contiguous subarrays whose length is between l and r (inclusive).
A subarray is a contiguous sequence of elements within the array. You need to consider all possible subarrays with lengths from l to r, calculate their sums, and return the smallest sum that is greater than 0.
If no such subarray exists (i.e., all valid subarrays have sums โค 0), return -1.
Example: For array [2, -1, 3, -4, 5] with l=2, r=3, we check subarrays of length 2 and 3. The subarray [2, -1] has sum 1, which might be our answer if it's the minimum positive sum found.
Input & Output
Constraints
- 1 โค nums.length โค 100
- 1 โค l โค r โค nums.length
- -1000 โค nums[i] โค 1000