TuSimple Interview Question

a medium to hard coding challenge