1800. Maximum Ascending Subarray Sum

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1800

class Solution:
    def maxAscendingSum(self, nums: List[int]) -> int:
        res = t = 0
        for i, v in enumerate(nums):
            if i == 0 or v > nums[i - 1]:
                t += v
                res = max(res, t)
            else:
                t = v
        return res