Find the greater element using stack


my one case is wrong please tell mistake

@lovish2552 check for this
5
2 1 2 1 3

please modify my code

@lovish2552 ok wait will send after correcting

@lovish2552 corrected


ngl tells next greater for ith element
as array is circular attached the same array twice
this last line was your mistake
4
8 2 3 6
ans
-1 3 6 8

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.