Bloomberg interview question

Leetcode style problem - data structures related