Leetcode 1413. Minimum Value to Get Positive Step by Step Sum | | Leetcode 1413. Minimum Value to Get Positive Step by Step Sum 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution Version 1 123456789101112class Solution: def minStartValue(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: return 1 else: return 1 - min_value Version 2 123456789class Solution: def minStartValue(self, nums): min_value = 0 total = 0 for num in nums: total += num if total < min_value: min_value = total return 1 - min_value Reference https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏