Pergunta de entrevista da empresa WizCommerce

Leetcode easy medium question: how to find nearest greater element for each each element in a array.