Amazon interview question

Coding question, hashmap followed by some changes.