Synaptic interview question

Leetcode hard based on Next greater element LLD