Topic: Stack Problem / Level: intermediate

Problem: Implement a stack to find the nearest greater and smaller elements for each element in an array.

Run the code to see the output here...