Pergunta de entrevista da empresa Microsoft

Leetcode medium difficulty.