Very easy DFS based solution......have a look


#1

int find_path(int curr,int des,vector<vector> &adj,vector &visited)
{
visited[curr]=1;
if(curr==des)
return 1;

for(auto val: adj[curr])
{
    if(visited[val]==0)
    {
        if(find_path(val,des,adj,visited))
        return 1;
    }
}
return 0;

}
int Solution::solve(int A,vector<vector> &B) {
vector visted(A+1,0);
vector<vector> adj(A+1);
for(int i=0; i<B.size(); i++)
{
adj[B[i][0]].push_back(B[i][1]);
}
return find_path(1,A,adj,visted);
}