Amazon interview question

House Robber II from leetcode.