Pregunta de entrevista de Google

Leetcode array question with a some minor changes