Domanda di colloquio di Amazon

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