Pergunta de entrevista da empresa MoveWORK

Leetcode question that was medium