Find the greater element

One test case is not passing?

Hey
Can you post your code?

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.

no its not been cleared

@tusharjha9835
It has been demanded in the question that the greater element should lie on the right of the given element. But you are running the inner loop from 0 to n which is not correct. Instead the loop should run from (i + 1) to n and then again from 0 to (i - 1). This way the solution will be correct. Because in your earlier approach, you might have been printing an element which might have been lying to the left of index i even though there was a greater element to the right of index i.

I hope I’ve cleared your doubt. Please mark the doubt as resolved in case my answer has resolved your query.

i updated my code using stack but still one test case is not passing - https://ide.codingblocks.com/s/315447