#3364

Minimum Positive Sum Subarray

easy · 44.9% accepted · 158 likes · top 28%

array · sliding window · prefix sum

⊣ practice⊣ open on leetcode ↗

Description

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.

Solution