Leetcode 1514 Solution

This article provides solution to leetcode question 1514 (minimum-value-to-get-positive-step-by-step-sum)

https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum

Solution

class Solution: def minStartValue(self, nums: List[int]) -> int: min_sum = 0 s = 0 for num in nums: s += num min_sum = min(s, min_sum) return 1 - min_sum