Solution in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minReorder(int n, vector<vector<int>>& con)\n     {\n        vector<vector<int>> adj(n),bk(n);\n        vector<int> vis(n,0);\n        vis[0] =1;\n        for(auto a : con)\n        {\n            adj[a[0]].push_back(a[1]);\n            bk[a[1]].push_back(a[0]);\n        }\n        int ans=0;\n        queue<int> q;\n        q.push(0);\n        while(!q.empty())\n        {\n            int a = q.front();\n            vis[a] =1;\n            q.pop();\n            for( int no : adj[a])\n            {\n                if(!vis[no]){\n                    ans++;\n                    q.push(no);\n                }\n            }\n            for( int no : bk[a])\n            {\n                if(!vis[no])\n                {\n                    q.push(no);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']