Find the greater elemenet

I cannot able to get required output

@sulbh579
I’ve corrected your current approach

But your approach is N^2 while solution should be N
So please think about that

This code is not giving correct output
4,2,5 it is giving -1,5,-1

@sulbh579
Thanks for pointing it out
It was a small error
I’ve fixed it
You can check it now

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.