A tagging game shows a list of numbered tags, tags. When you collect a value v, you earn v points for every tag with that value, but then you may not collect the values v - 1 or v + 1 at all.
Write tagPoints(tags) that returns the most points you can earn.
Input: tags = [5,6,4] Output: 10
Collect 6 and 4, which are not consecutive values: 6 + 4.
Input: tags = [3,3,4,4,4,5] Output: 12
Collect every 4: 4 + 4 + 4. Taking the 3s and the 5 instead gives only 11.
1 <= tags.length <= 200001 <= tags[i] <= 10000Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #498 Collect Tag Points Without Neighbors. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.