class Solution {
public:
void findpath(vector<vector<int>>& graph,int start,int end,vector<int>& path,vector<vector<int>>& allpath){
path.push_back(start);
if(start==end){
allpath.push_back(path);
}
for(int i=0;i<graph[start].size();i++){
findpath(graph,graph[start][i],end,path,allpath);
}
path.pop_back();
}
vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {
vector<int> path;
vector<vector<int>> allpath;
findpath(graph,0,graph.size()-1,path,allpath);
return allpath;
}
};