Amazon interview question

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