i am getting wrong answer but passing the sample cases;
problem : [chef and digit jumps](https://www.codechef.com/LRNDSA08/problems/DIGJUMP)
#include <bits/stdc++.h>
using namespace std;
class Graph
{ public:
map<int,list<int>> l;
void addedge(int x ,int y)
{
l[x].push_back(y);
}
void print()
{
for(auto node_pair : l)
{
cout<<node_pair.first<<"->";
for(auto ngh: l[node_pair.first])
{cout<<ngh<<" , ";}
cout<<endl;
}
}
int bfs (int src,int dest)
{// cout<<"s"<<src<<" "<<"d"<<dest<<endl;
map<int,int> dist;
queue<int> q;
for( auto node_pair : l)
{ int node = node_pair.first;
dist[node]=INT_MAX;
}
dist[src]=0;
q.push(src);
while(!q.empty())
{
int n = q.front();
q.pop();
for(int ngh : l[n])
{
if(dist[ngh]==INT_MAX)
{q.push(ngh);
dist[ngh]=dist[n]+1;}
}
}
/* for(auto node_pair: l)
{
int node= node_pair.first;
cout<<node<<" "<<dist[node]<<endl;
} */
return dist[dest];
}
};
int main() {
string str;
cin>>str;
Graph g;
int i;
vector<int> s;
for(i=0;i<str.length();i++)
{
int x= str[i]-'0';
s.push_back(x);
}
for( i =0;i<s.size();i++)
{
if(i>0)
{ if(g.l.find(s[i])!=g.l.end())
{ auto it =g.l.find(s[i]);
s[i]= s[i]+10;
g.addedge((it->first),s[i]);}
g.addedge(s[i-1],s[i]);}
}
g.addedge(s[i-1],100);
// g.print();
// cout<<"x "<< x<<endl;
int x = s.size();
int ans= g.bfs(s[0],s[x-1]);
cout<<ans<<endl;
// your code goes here
return 0;
}