Pergunta de entrevista da empresa Amazon

I forget the question but it seems same one in leetcode