Amazon Interview Question

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