Rivian interview question

1 algorithm question to solve.