Using 0-1 BFS!!! Easy C++ Solution!!🔥🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nHere, we are using 0-1 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nHere, we are using 0-1 BFS. We will treat every edge which is already given hav weight 1 and the opposite of that edge as 0. Then we will apply BFS and find the total weight to reach the leaf nodes.\n\nNote: Here we are treating normal edges as weight 1 as we are applying the BFS from 0 to leaf nodes rather than leaf nodes to 0.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\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>>& connections) {\n        vector<vector<pair<int,int>>> graph(n);\n        for(auto &v: connections){\n            graph[v[0]].push_back({v[1],1});\n            graph[v[1]].push_back({v[0],0});\n        }\n        queue<pair<int,int>> q;\n        q.push({0,0});\n        vector<bool> vis(n,false);\n        int ans=0;\n        while(!q.empty()){\n            auto p=q.front();\n            q.pop();\n            vis[p.first]=true;\n            ans+=p.second;\n            for(auto &x: graph[p.first]){\n                if(vis[x.first])continue;\n                // cout<<p.first<<\' \'<<p.second<<\' \'<<x.first<<" "<<x.second<<endl;\n                q.push(x);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']