#include
#include
using namespace std;
int main()
{
queueq;
int n,i,a,ans=0,c;
cin>>n;
int b[n];
for(i=0;i<n;i++)
{
cin>>a;
q.push(a);
}
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n;i++)
{
if(b[i]==q.front())
{
ans=ans+1;
q.pop();
}
else
{
while(b[i]!=q.front())
{
c=q.front();
q.push©;
q.pop();
ans++;
}
}
}
cout<< ans;
return 0;
}
above is my code.
Sample testcase is passed.
But on submission output is showing wrong answer.
Please highlight the erroe in above code.