Pregunta de entrevista de Google

Medium leetcode question and its complexity analysis.