Problems > Delete and Earn > Editorial

Delete and Earn — Solution & Editorial

Back to the Problem

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)