Question d’entretien chez TuSimple

some algorithm question, leedcode medium-hard level