797. 所有可能的路径

797. 所有可能的路径_第1张图片

class Solution {
public:
    vectorpath;
    vector >ans;
    void dfs(vector>& graph,int x){
        if(x==graph.size()-1){
            ans.push_back(path);
            return ;
        }
        for(int i=0;i> allPathsSourceTarget(vector>& graph) {
        path.push_back(0);
        dfs(graph,0);
        return ans;
    }
};

你可能感兴趣的:(力扣刷题,深搜,深度优先,算法,leetcode)