Jane Street interview question

leetcode medium involving dictionaries and loops