1466. Reorder Routes to Make All Paths Lead to the City Zero
***\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
***\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> v(n,0);\n        v[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 answer=0;\n        queue<int> q;\n        q.push(0);\n        while(!q.empty()){\n            int a = q.front();\n            v[a] =1;\n            q.pop();\n            for( int no : adj[a]){\n                if(!v[no]){\n                    answer++;\n                    q.push(no);\n                }\n            }\n            for( int no : bk[a]){\n                if(!v[no]){\n                    q.push(no);\n                }\n            }\n        }\n        return answer;\n    }\n};\n```
['C++']