Pergunta de entrevista da empresa TuSimple

Coding interview, level of difficulty: average question.