One test case is failing.
I realize that n <= 10 ^ 6 , so my algo with n ^2 complexity will fail . Is there any optimized way of solving this OR if not what is the problem in my code and what test case is failing.
One test case is failing.
I realize that n <= 10 ^ 6 , so my algo with n ^2 complexity will fail . Is there any optimized way of solving this OR if not what is the problem in my code and what test case is failing.
Hi… so we can do this questions using stack… this is a variation of finding next greater element… the twist in this question is array is considered circular.
for normal next greater element u can read this https://www.geeksforgeeks.org/next-greater-element/
soln to this ques is https://ide.codingblocks.com/s/587243
if u still face any difficulty msg back here
I got it…thanks
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.