Morgan Stanley interview question

Q: Solve this coding problem using a hash map