Pregunta de entrevista de Publicis Sapient

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