Pergunta de entrevista da empresa IXL Learning

Leetcode question, not too hard