535. Delete and Earn
Given an array of integers called 'nums', the goal is to maximize the total number of points earned by performing the following operation any number of times: - Select any element 'nums[i]' and delete it to earn 'nums[i]' points. - After deleting 'nums[i]', all elements equal to 'nums[i] - 1' and 'nums[i] + 1' must also be deleted. Find the maximum number of points that can be earned by applying the above operation some number of times.
The first line of input contains an integer 'N', representing the size of the array. The second line contains 'N' space-separated integers, representing the elements of the array.
Print the maximum number of points that can be earned.
6 2 2 3 3 3 4
1 <= n <= 10^4 1 <= nums[i] <= 10^4