Pergunta de entrevista da empresa Rivian

1 algorithm question to solve.