6
0
:0
0
Maximum Lift Interval
Maximum Lift Interval
Hard
Dynamic Programming
In "Maximum Lift Interval", each integer represents gain or loss at each time step.
Find the maximum possible sum of a contiguous non-empty segment.
Example 1
Input:
nums = [-2,13,-1,14,-3,15]Output:
38For input nums = [-2,13,-1,14,-3,15], the contiguous subarray [13,-1,14,-3,15] gives the maximum sum 38. Therefore, return 38.
Example 2
Input:
nums = [13,-1,-2,17,-1,2]Output:
28For input nums = [13,-1,-2,17,-1,2], the contiguous subarray [13,-1,-2,17,-1,2] gives the maximum sum 28. Therefore, return 28.
Constraints
1 <= nums.length <= 105-104 <= nums[i] <= 104
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[-2,13,-1,14,-3,15]Expected Output:
38Test Case 2
Input:
[13,-1,-2,17,-1,2]Expected Output:
28