Flexport Interview Question

Data structures/algorithms, around medium difficulty.