Pergunta de entrevista da empresa Amazon

Leetcode level problem very difficult