Find the greater element in circular queue

in this que we are comparing 3 with 1?because it is a circular qeue nd element next to 3 is 1…

@tishya_goyal yes we are, infact we don’t only consider next element but uptill we come back to the same element.
Example : for given input
4
3 1 5 4
desired output is : 5 5 -1 5


whats wrong in this code?

You are just checking it with previous element, which is not correct!, you have to start from ahead of current element and mark first greater element encountered (else -1) . Just think how can this be done for linear array first(don’t think about circular queue)

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.