Pregunta de entrevista de TuSimple

Coding interview, level of difficulty: average question.