classSolution: defminStartValue(self, nums): min_value = nums[0] total = 0 for num in nums: total += num if total < min_value: min_value = total if min_value >= 1: return1 else: return1 - min_value
Version 2
1 2 3 4 5 6 7 8 9
classSolution: defminStartValue(self, nums): min_value = 0 total = 0 for num in nums: total += num if total < min_value: min_value = total return1 - min_value