Domanda di colloquio di Publicis Sapient

Array leetcode easy question. They just wanted to know the approach.