← Discussions on Next Greater Element (Circular)
M mihir_97
08 Aug 2026, 18:08

Asked in my CRED OA last week.

A monotonic stack is the trick: pop while the current element breaks the order, and the popped elements have just found their answer.

2 replies

omkarsha4 2 months, 1 week ago

This should be marked as the editorial approach honestly.

hkapoor 2 months ago

Same idea, but I used a deque. Works fine.

Sign in to reply.