Morgan Stanley Interview Question

Q: Solve this coding problem using a hash map