Practice Minimum Positive Sum Subarray
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array nums and two integers l and r. Your task is to find the minimum sum of a subarray whose size is between l and r (inclusive) and whose sum is greater than 0. Return the minimum sum of such a subarray. If no such subarray exists, return -1. A subarray is a contiguous non-empty sequence of elements within an array.
Source: Minimum Positive Sum Subarray on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [3, -2, 1, 4], l = 2, r = 3
1
# Example 2
nums = [-2, 2, -3, 1], l = 2, r = 3
-1
# Example 3
nums = [1, 2, 3, 4], l = 2, r = 4
3
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Positive Sum Subarray .
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.