C++ Fast and Intuitive Approach
Intuition\nUse DFS and a reverse graph to traverse.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nWe create two adjacency lists. 
# Intuition\nUse DFS and a reverse graph to traverse.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nWe create two adjacency lists. One of original graph and other of reverse of that graph(all edges direction reversed).\nWe create a queue from which we start dfs.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    void dfs(vector<vector<int>> & gr, vector<vector<int>> & gr2, vector<bool> &vis, int s, int &ans, queue<int> &q)\n    {\n        if(vis[s]) return;\n        vis[s] = true;\n        //  cout<<"dfs "<<s<<endl;\n\n        for(int adj: gr2[s])\n        {\n            q.push(adj);\n            // cout<<"push "<<adj<<endl;\n        }\n\n        for(int e:gr[s])\n        {\n            if(!vis[e])\n            {\n                ans++;\n                dfs(gr, gr2, vis, e, ans, q);\n            }\n        }\n    }\n\n    int minReorder(int n, vector<vector<int>>& connections) {\n        int ans = 0;\n        vector<bool> vis(n, false);\n        vector<vector<int>> gr(n);\n        vector<vector<int>> gr2(n);\n\n        for(auto v:connections)\n        {\n            gr[v[0]].push_back(v[1]);\n            gr2[v[1]].push_back(v[0]);\n        }\n\n        queue<int> q;\n        q.push(0);\n\n        while(q.size())\n        {\n            int x = q.front();\n            q.pop();\n            dfs(gr, gr2, vis, x, ans, q);\n        }\n         return ans;\n    }\n};\n```
['Depth-First Search', 'Graph', 'Queue', 'C++']