Skip to content

Practice Minimum Value to Get Positive Step by Step Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1413
LeetCode Problem

Minimum Value to Get Positive Step by Step Sum

Problem Statement

Given an array of integers nums, you start with an initial positive value startValue. In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right). Return the minimum positive value of startValue such that the step by step sum is never less than 1.

Source: Minimum Value to Get Positive Step by Step Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [-3,2,-3,4,2]
Output
5

# Example 2

Input
nums = [1,2]
Output
1

# Example 3

Input
nums = [1,-2,-3]
Output
5

Constraints

1 <= nums.length <= 100
-100 <= nums[i] <= 100

Related LeetCode Problems

Practice more problems similar to Minimum Value to Get Positive Step by Step Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.