6
0
:0
0
Player Combo Maximum
Player Combo Maximum
Medium
Dynamic Programming
In "Player Combo Maximum", 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,9,-1,10,-3,11]Output:
26For input nums = [-2,9,-1,10,-3,11], the contiguous subarray [9,-1,10,-3,11] gives the maximum sum 26. Therefore, return 26.
Example 2
Input:
nums = [9,-1,-2,13,-1,2]Output:
20For input nums = [9,-1,-2,13,-1,2], the contiguous subarray [9,-1,-2,13,-1,2] gives the maximum sum 20. Therefore, return 20.
Constraints
1 <= nums.length <= 105-104 <= nums[i] <= 104
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[-2,9,-1,10,-3,11]Expected Output:
26Test Case 2
Input:
[9,-1,-2,13,-1,2]Expected Output:
20