Compass interview question

Leetcode medium (hashmaps, trees)