Pergunta de entrevista da empresa TuSimple

very similar to Leetcode 1463, cherry pick up II