straightforward c++ solution || bfs
We put outward facing edges in one vector, and keep the reverse in another.  \n\nStarting from the city, we switch edges that are facing away from us.  \n\nIf t
We put outward facing edges in one vector, and keep the reverse in another.  \n\nStarting from the city, we switch edges that are facing away from us.  \n\nIf there is a node that faces inward to us that we haven\'t visited yet, it would be in our back vector. \nWe need to add inward facing nodes to the queue as well, since they might have neighbors that need to be flipped.\n\n```\n\tint minReorder(int n, vector<vector<int>>& connections) {\n        vector<int> visited(n);\n        vector<vector<int>> adj(n), back(n);\n        queue<int> q;\n        q.push(0);\n        int ans = 0;\n        \n        for (auto c : connections){\n            adj[c[0]].push_back(c[1]);\n            back[c[1]].push_back(c[0]);\n        }\n        \n        while (!q.empty()){\n            int curr = q.front();\n            q.pop();\n            visited[curr] = 1;\n\n            // change dir for all arrows facing out\n            for (auto a: adj[curr]){\n                if (!visited[a]){\n                    ans++;\n                    q.push(a);\n                }\n            }\n            // push other nodes so we visit everything\n            for (auto b: back[curr]){\n                if (!visited[b]) q.push(b);\n            }\n        }\n        return ans;\n    }\n```
['Breadth-First Search', 'C']