A single test case is failing in this problem of finding the greater element

How do i make the array circular?
And another case could be what if all the numbers in the array are same?
How do I handle those cases?

Hello @Vishesh-Chaitanya-1475805525886480check In the circular way it is given that you are given with the circular array.

How to handle the failing test case?

What all changes shall be made??

@Vishesh-Chaitanya-1475805525886480 please wait i am checking.

@Vishesh-Chaitanya-1475805525886480 do this question with indexing so if at any point you have indexing in the stack then you can handle the location and the element as well:
and at that index you can add elements also.

@Vishesh-Chaitanya-1475805525886480 check this code:
https://ide.codingblocks.com/s/430946

How to handle the failing test case ?? And what is the error in this code ?

if the first element of the array is greater then the last element then the next greater for the last element will be the first element.
this is the problem with your code.

Got it @Tushar , thanks a lot .

@Vishesh-Chaitanya-1475805525886480 Happy to help you.
if you feel that your doubt is cleared you can mark this as resolved.

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.