Here's a practice problem: you have cards with values . You can take cards, but if you take card , all cards with values and are destroyed. get the highest total points.
This is Boredom in disguise. Count the frequency of each value. The total points from taking all cards of value is .
Now it's House Robber on the value array. Try coding it yourself. The key steps: count frequencies, find max value, run House Robber DP on the frequency array. Time: where is the maximum card value. Space: for the frequency array, or with state compression.