// 1800. Maximum Ascending Subarray Sum
class Solution {
public int maxAscendingSum(int[] nums) {
int ans = nums[0];
int current = nums[0];
for (int i = 1; i < nums.length; ++i) {
if (nums[i] > nums[i - 1]) {
current += nums[i];
} else {
current = nums[i];
}
if (current > ans) {
ans = current;
}
}
return ans;
}
}
学习笔记: 这是一道简单的数组水题。