1800. Maximum Ascending Subarray Sum

Updated: 2024-03-12
1 min read
[]

On This Page

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