Question d’entretien chez Amazon

Stack question based on next greater element.