Moovit Interview Question

leetcode question about data structures