Amazon Interview Question

The most difficult part is about how to select a data structure to solve the problem effectively.