int Solution::snakeLadder(vector<vector > &A, vector<vector > &B)
{
unordered_map<int,int>m;
for(int i=0;i<A.size();i++)
{
m[A[i][0]]=m[A[i][1]];
}
for(int i=0;i<B.size();i++)
{
m[B[i][0]]=m[B[i][1]];
}
queueq;
int moves=0;
q.push(1);
bool visi[101]={false};
int found=0;
visi[1]=true;
int y;
while(!q.empty() && found!=1)
{
int s=q.size();
while(s–)
{
int x=q.front();
q.pop();
for(int j=1;j<=6;j++)
{
y=x+j;
if(y==100)
{
found=1;
break;
}
if(m.find(y)!=m.end() && visi[y]==false && y<=100)
{
y=m[y];
}
if(m.find(y)==m.end() && visi[y]==false && y<=100)
{
y=m[y];
}
if(visi[y]==false && y<=100)
{
visi[y]=true;
q.push(y);
}
}
}
moves++;
}
if(found==1)
{
return moves;
}
else
{
return -1;
}
}
my code is failing on this testcase