Morgan Stanley Interview Question

Data structures coding challenge.