Pergunta de entrevista da empresa Amazon

Find next greater element for each of the elements in the array.