Concise DFS | C++
\nclass Solution {\n    int dfs(int node, int prnt, vector<pair<int, int>> adj[]) {\n        int cnt = 0;\n        for(auto ad : adj[node]) {\n            if(ad
```\nclass Solution {\n    int dfs(int node, int prnt, vector<pair<int, int>> adj[]) {\n        int cnt = 0;\n        for(auto ad : adj[node]) {\n            if(ad.first == prnt) continue;\n            cnt += ad.second + dfs(ad.first, node, adj);\n        }\n        return cnt;\n    }\npublic:\n    int minReorder(int n, vector<vector<int>>& connections) {\n        vector<pair<int, int>> adj[n];\n        for(auto e : connections) {\n            adj[e[0]].push_back({e[1], 1});\n            adj[e[1]].push_back({e[0], 0});\n        }\n        return dfs(0, -1, adj);\n    }\n};\n```
['Depth-First Search', 'C++']