Minimum Value to Get Positive Step by Step Sum Problem

Minimum Value to Get Positive Step by Step Sum Problem — ExecCode Easy DSA Practice

Solve the Minimum Value to Get Positive Step by Step Sum problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array of integers nums, you start with an initial positive value startValue. Your task is to compute the required answer and return the minimum positive value of startValue such that the step by step sum is never less than 1. In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).

Examples

Input {"nums": [-3, 2, -3, 4, 2]}; Output 5. Input {"nums": [1, 2]}; Output 1

Constraints

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

Practice Minimum Value to Get Positive Step by Step Sum free on ExecCode. Browse DSA problems, topic map, and placement guides.