Monotonic stack

Keep a stack in sorted order to find the next greater or smaller element for every position in one pass.

Solved

0/6