Okta Interview Question

Similar to House Robber, need to solve by dp