Rivian interview question

Leetcode medium/hard