Problem
You are given an array nums. In one move you pick any nums[i], earn nums[i] points, and remove it. Every element equal to `nums[i] - 1` or `nums[i] + 1` is then deleted too, for no points. Return the maximum points you can earn.
Example 1
- Input
- nums = [3, 4, 2]
- Output
- 6
- Why
- take 4, which deletes the 3; then take 2
Example 2
- Input
- nums = [2, 2, 3, 3, 3, 4]
- Output
- 9
- Why
- take all three 3s
Example 3
- Input
- nums = [1]
- Output
- 1
Constraints
1 <= nums.length <= 2 * 10^41 <= nums[i] <= 10^4