Problem 3840 · Medium

House Robber V

Rob houses in a row with a rule that two neighbours of the same colour cannot both be taken; a two-state dynamic programme tracks whether the previous house was robbed.

Open the interactive visualisation