C++ || line by line explanation
Intuition\nWe need find the number of road to rearrange  in other words number of roads to reverse to reach 0 from each and every node.\n\n# Approach\nWe are go
# Intuition\nWe need find the number of road to rearrange  in other words number of roads to reverse to reach 0 from each and every node.\n\n# Approach\nWe are going to use concept of incoming and out-going edges in node.\n\n\nLet\'s start solving this problem along with code and explanaion of logic behiend each step.....\n\nfirst we are going to find adjency list without making changes and one with reverse all the direction of edges. logic behind doing this ... if i could visite some cities/nodes from "A" (Node 0) given city/node that means we can\'t visit "A" (Node 0) from all visited cities and we need to reverse the direction of each road/edges to visit "A" (node 0).\n```\nfor(auto a : con){\n  adj[a[0]].push_back(a[1]); // this is correce adjency list\n  bk[a[1]].push_back(a[0]); // this is reverse adjencct list\n}\n```\nWe need a visited array that is for record of visted city/node\n```\nvector<int> vis(n,0);\n```\nNow start traversing by DFS/BFS and find number of cities/node you can visit from node 0 (these are the node which are not coming to node 0) these will be part of our answer.\n```\nqueue<int> q;\n        q.push(0);\n        while(!q.empty()){\n            int a = q.front();\n            vis[a] =1;\n            q.pop();\n            for( int no : adj[a]){\n                if(!vis[no]){\n                    ans++;\n                    q.push(no);\n                }\n            }\n            for( int no : bk[a]){\n                if(!vis[no]){\n                    q.push(no);\n                }\n            }\n        }\n```\nbelow part of code is to visit all outgoing rodes that will be part of our answer\n```\nfor( int no : adj[a]){\n  if(!vis[no]){\n    ans++;\n    q.push(no);\n  }\n}\n```\nthis part of code to visit all the incoming roads .  city/nodes that are incoming and marking them visited so that not to reapetaion of visiting...\n```\nfor( int no : bk[a]){\n  if(!vis[no]){\n    q.push(no);\n  }\n}\n```\n\n==========================================================\n```\nREAD IT ? VOTE UP .... give us motivation to continue.\n```\n==========================================================\n\n\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        vector<vector<int>> adj(n) , bk(n);\n        vector<int> vis(n,0);\n        vis[0] =1;\n        for(auto a : con){\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            int a = q.front();\n            vis[a] =1;\n            q.pop();\n            for( int no : adj[a]){\n                if(!vis[no]){\n                    ans++;\n                    q.push(no);\n                }\n            }\n            for( int no : bk[a]){\n                if(!vis[no]){\n                    q.push(no);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']