House robber

easy

Rob house i and you must have skipped i−1, so you add to dp[i−2]. The adjacency constraint lives entirely in that index gap - and only two previous values are ever read.

Worst O(n)Space O(1) after the rolling-variable optimisation
Loading the house robber engine…

Where to go next