Morgan Stanley interview question

Programming Puzzles and Data Structures