1514. Minimum Value to Get Positive Step by Step Sum
My accepted Python solution to LeetCode problem 1514, Minimum Value to Get Positive Step by Step Sum, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2025-12-29.
class Solution:
def minStartValue(self, nums: List[int]) -> int:
min_prefix = 0
prefix_sum = 0
for num in nums:
prefix_sum += num
min_prefix = min(min_prefix, prefix_sum)
return max(1, 1 - min_prefix)