Pergunta de entrevista da empresa Amazon

Coding question, hashmap followed by some changes.