627. Minimum Value to Achieve Positive Cumulative Sum
0
Easy
Given an array of integers nums, you start with an initial positive value startValue. During each iteration, you calculate the cumulative sum of startValue plus elements in nums (from left to right). Find the minimum positive value of startValue such that the cumulative sum is never less than 1.
Input Format
The first line contains a single integer N.
The second line contains an array nums.
The second line contains an array nums.
Output Format
An integer representing the minimum positive value of startValue.
Example
Input
5
-3 2 -3 4 2
Output
5
Constraints
1 <= N <= 10^4
Loading...
View Submissions
Console