TuSimple Interview Question

a graph problem in disguise