Pergunta de entrevista da empresa Okta

Similar to House Robber, need to solve by dp