TuSimple Interview Question

dynamic programming and searching problem