whats error in my code , I am getting run time error +segmentation fault with some test cases
here is my code __;-
#include<bits/stdc++.h>
using namespace std;
#define vi vector
#define ll unsigned long long int
#define pp long long int
#define pb push_back
#define mp make_pair
#define eb emplace_back
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int a[n]={0};
stacks1,s2,s3;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=n-1;i>=0;i–)
{
s1.push(a[i]);
}
int j=1;
while(!s1.empty())
{ cout<<1;
if(s1.top()==j)
{
s1.pop();
j++;
}
else if(s2.top()==j&&s2.size()!=0)
{
s2.pop();
j++;
}
else
{
s2.push(s1.top());
s1.pop();
}
}
int flag=0;
while(!s2.empty())
{
if(j==s2.top())
{
j++;
s2.pop();
}
else
{
flag=1;
break;
}
}
if(flag==0)
{
cout<<“yes”<<endl;
}
else
{
cout<<“no”<<endl;
}
return 0;
}