reorder routes to make all paths lead to the city zero
Intuition\nstore all given connections in a adjaceny list smartly (in pair form) such that given connections can be checked and created connection can be checke
# Intuition\nstore all given connections in a adjaceny list smartly (in pair form) such that given connections can be checked and created connection can be checked at the time of dfs function working\n\n# Approach\nnow let\'s talk about complete approach i stored all given connection in a adjaency list of pairs such that storing connected node contains 0 with other node and myself created node contains -1 with other node  (why i do it because when i call dfs i can know when i call dfs  for child then i can checked if it comes from given connection or it comes from my created connections and increase the counter if it comes from my created connections ( how i checked from where it comes > just check if its pair\'s second element if 0 or 1 (see code for clarification)))\n\n# Complexity\n- Time complexity:\nO(n+m)\n\n- Space complexity:\nO(n+m)\n\n# Code\n```\nclass Solution {\npublic:\n\n    void dfs(int node,vector<pair<int,int>>adj[],int &cnt,vector<bool>&vis)\n    {\n        vis[node]=true;\n        for(auto child:adj[node])\n        {\n            auto it=child.first;\n            if(!vis[it])\n            {\n                if(child.second)\n                {\n                    cnt++;\n                }\n                dfs(it,adj,cnt,vis);\n            }\n        }\n    }\n    int minReorder(int n, vector<vector<int>>& v) {\n        vector<pair<int,int>>adj[n];\n        for(int i=0;i<v.size();i++)\n        {\n            adj[v[i][0]].push_back({v[i][1],-1});\n            adj[v[i][1]].push_back({v[i][0],0});\n        }\n        int cnt=0;\n        vector<bool>vis(n,false);\n        dfs(0,adj,cnt,vis);\n        return cnt;\n\n    }\n};\n```
['Greedy', 'Graph', 'C++']