Pergunta de entrevista da empresa Microsoft

Leetcode 636 as it is was asked