Morgan Stanley Interview Question

Data structures, time complexity