Pergunta de entrevista da empresa Google

Leetcode 113 but with variation