public int maxAscendingSum(int[] nums) {
int n = nums.length, ans = nums[0];
for (int i = 1, cur = nums[0]; i < n; i++) {
if (nums[i] > nums[i - 1]) cur += nums[i];
else cur = nums[i];
ans = Math.max(ans, cur);
}
return ans;
}
2022.10.7-----leetcode.1800
最新推荐文章于 2024-11-05 21:58:11 发布