0
点赞
收藏
分享

微信扫一扫

LeetCode题解(1800):最大升序子数组和(Python)


题目:​​原题链接​​(简单)

标签:双指针

解法

时间复杂度

空间复杂度

执行用时

Ans 1 (Python)

40ms (63.72%)

Ans 2 (Python)

Ans 3 (Python)

解法一:

class Solution:
def maxAscendingSum(self, nums: List[int]) -> int:
ans = 0
now = 0
last = 0
for num in nums:
if num > last:
now += num
else:
now = num
last = num
ans = max(ans, now)
return


举报

相关推荐

0 条评论