My issue
Why am I getting runtime error.?
My code
class solution {
public:
int getMinimumServers(int n, vector<pair<int, int>>ser){
// Complete the code
vector<int>Graph[n+1];
for(auto p:ser)
{
Graph[p.first].push_back(p.second);
Graph[p.second].push_back(p.first);
}
queue<int>pend;
pend.push(1);
int fine=-1;
vector<bool>visited(n+1,false);
int ans=0;
while(!pend.empty())
{
int ft=pend.front();
pend.pop();
for(int adj:Graph[ft])
{
if(adj==n) return 1+ans;
if(!visited[adj]) pend.push(adj);
}
ans++;
}
return -1;
}
};
Learning course: Graphs
Problem Link: Chef Shortest Route Practice Problem in Graphs - CodeChef