Pergunta de entrevista da empresa Amazon

The code question is leetcode 136