Morgan Stanley interview question

Data structures coding challenge.