Question d’entretien chez Publicis Sapient

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