Pregunta de entrevista de Rivian

1 algorithm question to solve.