Pregunta de entrevista de Google

a question from leetcode that was easy level