Pregunta de entrevista de Amazon

Coding question, hashmap followed by some changes.