TuSimple interview question

some algorithm question, leedcode medium-hard level