Video solution | Intuition explained in detail | C++ | DFS
Video\nHey everyone i have created a video solution for this problem (its in hindi), it involves intuitive explanation with code, this video is part of my playl
# Video\nHey everyone i have created a video solution for this problem (its in hindi), it involves intuitive explanation with code, this video is part of my playlist "Master Graphs"\nVideo link : https://www.youtube.com/watch?v=1aQPv0yDihs\nPlaylist link: : https://www.youtube.com/playlist?list=PLICVjZ3X1AcZ5c2oXYABLHlswC_1LhelY\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int count=0;\n\n    void dfs(vector<vector<int>>& adj, int src, vector<bool>& visited){\n        visited[src]=true;\n        for(auto connectedCity: adj[src]){\n            if(!visited[abs(connectedCity)]){\n                if(connectedCity>0){\n                    count++;\n                }\n                dfs(adj,abs(connectedCity),visited);\n            }\n        }\n        \n\n    }\n    int minReorder(int n, vector<vector<int>>& connections) {\n        vector<vector<int>> adj(n);\n\n        vector<bool> visited(n,false);\n\n        for(int i=0;i<connections.size();i++){\n            adj[connections[i][0]].push_back(connections[i][1]);\n            adj[connections[i][1]].push_back(-connections[i][0]);\n\n        }\n        dfs(adj, 0, visited);\n\n        return count;\n        \n    }\n};\n```
['C++']