Pergunta de entrevista da empresa Amazon

Solve this coding problem (related to dictionaries and counting).