Greater element of stack

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[10000];
for(int i=0;i<n;i++) cin>>a[i];
stack s;
s.push(a[0]);
for(int i=1;i<n;i++){

while(!s.empty()&&s.top()<a[i]){
cout<<a[i]<<" ";
s.pop();
}
s.push(a[i]);
}
while(!s.empty())
{
cout<<-1<<" ";
s.pop();
}

}

getting the right output but I did not understand how are we implementing a circular array in this code

you have to go through 2 passes of the array in order to get the answer .

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.