dfs
\nclass Solution {\npublic:\n    \n    void dfs(vector<vector<pair<int,int>>> &g,int s, int &cnt,vector<bool> &v)\n    {\n        if(v[s]){\n            return 
```\nclass Solution {\npublic:\n    \n    void dfs(vector<vector<pair<int,int>>> &g,int s, int &cnt,vector<bool> &v)\n    {\n        if(v[s]){\n            return ;\n        }\n        v[s]  = true;\n        \n        for(auto &i: g[s])\n        {   \n            if(!v[i.first]){\n                cnt+=i.second;\n                dfs(g,i.first,cnt,v);\n            }\n        }\n    }\n    \n    \n    int minReorder(int n, vector<vector<int>>& c) {\n        vector<vector<pair<int,int>>> g(n);\n        vector<bool> v(n,false);\n        \n        for(auto &i: c)\n        {\n            g[i[0]].push_back({i[1],1});\n            g[i[1]].push_back({i[0],0});\n        }\n        \n        int cnt = 0;\n        dfs(g,0,cnt,v);\n        return cnt;\n    }\n};\n```
['C']