Skip to content

Commit d9c8a92

Browse files
committed
add Maximum Ascending Subarray Sum in python
1 parent cf50630 commit d9c8a92

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def maxAscendingSum(self, nums: List[int]) -> int:
3+
curSum = results = nums[0]
4+
5+
for i in range(1, len(nums)):
6+
if nums[i] <= nums[i - 1]:
7+
curSum = 0
8+
curSum += nums[i]
9+
results = max(curSum, results)
10+
11+
return results

0 commit comments

Comments
 (0)