Pregunta de entrevista de Meta

Medium level leetcode I would say