https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/
Minimum Value to Get Positive Step by Step Sum - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
class Solution:
def minStartValue(self, nums: List[int]) -> int:
start=1
while True:
total = start
is_valid = True
for i in nums:
total += i
if total < 1:
is_valid = False
break
if is_valid:
return start
else:
start+=1