Pregunta de entrevista de Meta

An algorithm question from Leetcode