values. In one move you take any card and score as many points as it shows. Every card whose value is exactly one less or one more than the card you took then burns and can no longer score.
You may make as many moves as you like. Return the largest score you can get.values=[4, 10, 5, 4] → 18
Take both 4s (the 5 burns) and the 10: 4 + 4 + 10 = 18. Starting with the 5 would burn both 4s and leave just 15.
values=[1, 1, 2, 3, 3, 3] → 11
It pays to give up the 2: the 1s give 2 points and the 3s give 9, 11 in total.
values=[4, 10, 5, 4]
18
Run checks the first 3 tests in your browser. Submit checks all 116 tests on the server, hidden ones included.