Maximum Ascending Order Subarray Sum
Given an array of positive integers nums
, find the maximum sum of an ascending subarray.
Return the maximum possible sum among all ascending subarrays.
nums = [5, 15, 25, 10, 20, 30]
60
The subarray [10, 20, 30]
has the maximum sum of 50
.
nums = [3, 6, 9, 12]
30
The entire array [3, 6, 9, 12]
is ascending, with a sum of 30
.
nums = [8, 7, 6, 5, 4]
8
Each element is in descending order, so the maximum sum is the largest single element: 8
.
nums = [2, 2, 2, 2]
2
All elements are equal, so no two consecutive elements form an ascending sequence. The maximum sum is any single element: 2
.
1 <= nums.length <= 100
1 <= nums[i] <= 100
https://leetcode.com/problems/maximum-ascending-subarray-sum
Loading component...
Loading component...