Topic: Stack Problem / Level: intermediate

Problem: Create a function to solve the problem of finding the nearest greater element on both sides of each element in an array using a stack.

Run the code to see the output here...