← 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 3 months, 3 weeks ago

This should be marked as the editorial approach honestly.

hkapoor 3 months, 2 weeks ago

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

Sign in to reply.