BFS C++ Bidirectional easy approach
\n\n# Code\n\nclass Solution {\npublic:\n    int minReorder(int n, vector<vector<int>>& connections) {\n        vector<vector<pair<int, bool>>> adj_list(n);\n  
\n\n# Code\n```\nclass Solution {\npublic:\n    int minReorder(int n, vector<vector<int>>& connections) {\n        vector<vector<pair<int, bool>>> adj_list(n);\n        int count = 0;\n        for(int i=0; i<connections.size(); i++){\n            adj_list[connections[i][0]].push_back({connections[i][1], false});\n            adj_list[connections[i][1]].push_back({connections[i][0], true});\n        }\n        queue<pair<int, bool>> q;\n        q.push({0, true});\n        vector<bool> vis(n, false);\n        vis[0] = true;\n        while(!q.empty()){\n            int node = q.front().first;\n            q.pop();\n            for(int i=0; i<adj_list[node].size(); i++){\n                if(!vis[adj_list[node][i].first] && adj_list[node][i].second == false){\n                    count++;\n                }\n                if(!vis[adj_list[node][i].first]) {\n                    q.push(adj_list[node][i]);\n                    vis[adj_list[node][i].first] = true;\n                }\n            }\n        }\n        return count;\n    }\n};\n```
['Breadth-First Search', 'C++']