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.
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.
This should be marked as the editorial approach honestly.
Same idea, but I used a deque. Works fine.
Sign in to reply.