This commit is contained in:
parent
b7a6218dbc
commit
d0df9b92ca
1 changed files with 16 additions and 0 deletions
16
easy/maximum_ascending_subarray_sum.py
Normal file
16
easy/maximum_ascending_subarray_sum.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# https://leetcode.com/problems/maximum-ascending-subarray-sum
|
||||
|
||||
from typing import List
|
||||
|
||||
class Solution:
|
||||
def maxAscendingSum(self, nums: List[int]) -> int:
|
||||
result = 0
|
||||
curr = nums[0]
|
||||
for i in range(1, len(nums)):
|
||||
if nums[i - 1] >= nums[i]:
|
||||
result = max(result, curr)
|
||||
curr = 0
|
||||
curr += nums[i]
|
||||
result = max(result, curr)
|
||||
return result
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue