所有可能的路径
class Solution { public: vector<vector<int>> result; vector<int> path; void dfs(vector<vector<int>>& graph , int indnx) { if(indnx == graph.size()-1) { path.push_back(graph.size()-1); result.push_back(path); path.pop_back(); return; } for(int i=0 ; i<graph[indnx].size() ;i++) { path.push_back(indnx); dfs(graph,graph[indnx][i]); path.pop_back(); } return; } vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) { dfs(graph,0); return result; } };