Best Ascent — Advanced DP
Find the largest calorie total over a run of consecutive minutes where each burns more than the minute before it; a single minute also qualifies.
Advanced DP · Easy
The problem
You get a list of positive whole numbers. An ascent is a run of neighbouring numbers where each is strictly larger than the one before it, and a single number is an ascent of length one. Return the largest sum of any ascent.
The story
A fitness band logs the calories burned in each of up to 10 consecutive minutes, each a whole number from 1 to 20. A climb is a stretch of neighbouring minutes where each burns strictly more than the one before it, and one minute alone counts as a climb. Report the largest total calories burned over any single climb.
What to return
- Return the largest sum over all runs in which every number is strictly larger than the one before it.
Constraints
- 1 <= nums.length <= 10
- 1 <= nums[i] <= 20
Example
- Input
nums = [10, 20, 3, 5, 10, 19]- Output
37