Amazon interview question

Maps, Recursion, and good OOP are your friends.