TuSimple interview question

BFS, DFS related coding problem