Next greater element problem

i am unable to find bug in this code

link to the code :

Hi soorya the time complexity of your code is n^2 so it will give a tle so think of a logic using stack which would reduce it to O(n)