Easy understand graph problems(C++)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\nint ans=0;\n    void dfs(unordered_map<int,vector<int>>&mp ,unordered_map<int,bool>&vis,int m){\n        vis[m]=true;\n        for(auto i:mp[m]){\n            if(i>=0){\n                if(!vis[i]){    \n                    dfs(mp,vis,i);\n                }\n            }\n            else{\n                i=abs(i);\n                if(!vis[i]){   \n                    ans++; \n                    dfs(mp,vis,i);\n                }\n            }\n        }\n    }\n    // ans++\n    // void sol(unordered_map<int,vector<int>>&mp ,unordered_map<int,bool>&vis,int m){\n    //     for(auto i:mp[m]) {\n    //         if(!vis[i]){\n    //             dfs(mp,vis,i);\n    //             ans++;\n    //         }\n    //     }\n    // }\n    int minReorder(int n, vector<vector<int>>& c) {\n        int s=c.size();\n        unordered_map<int,vector<int>>mp;\n        unordered_map<int,bool>vis;\n        for(int i=0;i<s;i++){\n            mp[c[i][1]].push_back(c[i][0]);\n            mp[c[i][0]].push_back(-c[i][1]);\n        }\n        dfs(mp,vis,0);\n        if(ans==0)return ans;\n        return ans;\n    }\n};\n```
['C++']