Amazon interview question

A leetcode style question relating to dicts