Given an array nums, choose numbers to earn points equal to their values times frequency. Choosing x removes x-1 and x+1 from consideration. Pattern focus: Take Or Skip DP. After compressing equal values, the problem reduces to a take-or-skip decision over sorted unique numbers.
nums = array of integers
maximum points obtainable
Example 1:
Input:
nums = [3,4,2]
Output:
6
Explanation:
Take 4 and 2.
Example 2:
Input:
nums = [2,2,3,3,3,4]
Output:
9
Explanation:
Taking 3 yields the best total.