Single testcase wrong output
You can solve this question using array only , no need of using stack . Since the array is circular , make a new array of double size of original array and copy the elements of original array twice . Now search in this new array
In your approach check the answer for
4
1 1 1 1
Your output should be -1 -1 -1 -1
Ok thank you very much. Yeah that approach would be easier to follow.