Moovit interview question

leetcode question about data structures