Delete and Earn — Solution & Editorial
Group by value: taking value v forbids v−1 — exactly the house-robber recurrence over the value axis with weights v·count(v).
Complexity: O(N + max)
Group by value: taking value v forbids v−1 — exactly the house-robber recurrence over the value axis with weights v·count(v).
Complexity: O(N + max)