My code works fine for normal array but it is not giving correct answer for circular array can you make changes in my code.
here is my code: https://ide.codingblocks.com/s/223780
Not able to handle testcases for circular array
please wait i am trying to debug
vector<int> vec(nums.size() , -1);
stack<int> st;
st.push(0);
int n = nums.size();
for(int i = 1 ; i < 2*n ; i++){
while(!st.empty() and nums[i%n] > nums[st.top()]){
vec[st.top()] = nums[i%n]; st.pop();
}
st.push(i%n);
}
hi @navin_japes
this much of code would do the entire work
just print the result vector at the end