Flexport interview question

Data structures/algorithms, around medium difficulty.