Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan)
Solve with full IDE support and test cases