Algorithm · Microsoft · Medium
Given an integer array nums, you may perform the following operation any number of times. Choose any remaining element, and let v be its value. Add v to your score and remove that element. Then remove every remaining element whose value is equal to v - 1 or v + 1. Return the maximum total score you can obtain. Example 1: Explanation: Take the values 4 and 6 in either order. Taking 4 removes all 3s and 5s, leaving 6 available; together they give 4 + 6 = 10. Taking 5 would…
Checking your access…