Skip to content

Commit

Permalink
Create 1800. Maximum ascending subarray sum
Browse files Browse the repository at this point in the history
  • Loading branch information
dishathakurata authored Feb 5, 2025
1 parent cc79eef commit 9158c38
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 1800. Maximum ascending subarray sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//1800. Maximum ascending subarray sum

class Solution {
public int maxAscendingSum(int[] nums) {
int curr = nums[0], ans = nums[0];

for(int i = 1; i < nums.length; i++) {
curr = nums[i] > nums[i - 1] ? curr + nums[i] : nums[i];
ans = Math.max(ans, curr);
}

return ans;
}
}

0 comments on commit 9158c38

Please sign in to comment.