Pergunta de entrevista da empresa Google

There was 2 hard Level Leetcode question.