Pregunta de entrevista de Meta

Two leetcode questions in medium difficulty.