Problem statement

https://binarysearch.com/problems/Minimum-Initial-Value-for-Positive-Prefix-Sums/

Solution

Evaluate cumulative sum and find min element.

Complexity

It is O(n) for time and O(1) for space.

Code

class Solution:
    def solve(self, nums):
        return max(1, 1 - min(accumulate([0] + nums)))