Pergunta de entrevista da empresa WillowTree

It was a leetcode question.