Pregunta de entrevista de MoveWORK

Leetcode question that was medium