Pregunta de entrevista de Google

Leetcode question number 30 code question