Find the largest sum of any contiguous strictly increasing segment in an array.
Problem
Given an integer array nums, consider every contiguous subarray whose values are strictly increasing from left to right.
Return the maximum possible sum of such a subarray.
A subarray must consist of consecutive elements, and for every adjacent pair in that subarray, the later element must be greater than the earlier one.
Input Format
- A single integer array
nums. numscontains one or more integers.
Output Format
- Return one integer: the maximum sum of any contiguous strictly increasing subarray.
Constraints
- The array length is at least 1.
- A valid subarray must be contiguous.
- Consecutive values in the chosen subarray must satisfy
nums[i] < nums[i + 1]. - Use 32-bit integer-safe reasoning where applicable.
Example 1
Input
nums = [10,20,30,5,10,50]
Output
65
Explanation
The strictly increasing subarray [5,10,50] has sum 65, which is the largest among all ascending subarrays.
Example 2
Input
nums = [12,17,15,13,10,11,12]
Output
33
Explanation
The best ascending subarray is [10,11,12], with sum 33.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.