182. Delete and Earn

Choose numbers from an array: for each x you earn x points, but you cannot take x-1 or x+1. Return the maximum points.
Example 1
Input: nums = [3,4,2]
Output: 6
Explanation: Take 3 and 2 (or 4 and 2) = 6.
Example 2
Input: nums = [2,2,3,3,3,4]
Output: 9
Explanation: Take all threes: 3+3+3 = 9.
arraysdynamic programmingmedium
JavaScript
Loading...
Line 1, Char 1