Java || DFS Solution || Explained Intuition and Approach
```\nclass Solution {\n    int count=0;\n    public int minReorder(int n, int[][] edges) {\n        // the graph which is provided is directed in different dirn
```\nclass Solution {\n    int count=0;\n    public int minReorder(int n, int[][] edges) {\n        // the graph which is provided is directed in different dirn\'s so we cannot reach all nodes if we start \n        // traversing the graph from zero node.\n        // to overcome this we make the graph directed in both ways , and new directed edge made by us will be marked\n        // by some value like 0(false), so that we know that this is not the actual directed edge but made by us\n        \n        List<List<int[]>> graph= new ArrayList<>();\n        \n        for(int i=0;i<n;i++)\n        {\n            graph.add(new ArrayList<>());\n        }\n        \n        for(int i=0;i<edges.length;i++)\n        {\n            int edge[] =  edges[i];\n            // we add 1 in pair which represents that the edge actually exists \n            graph.get(edge[0]).add(new int[]{edge[1],1});\n            // we add 0 in pair which represents that the edge actually does not exist and we have created it \n            graph.get(edge[1]).add(new int[]{edge[0],0});\n        }\n        \n        // we will apply dfs \n        boolean [] visited = new  boolean[n];\n        visited[0] = true;\n        dfs(graph, 0, visited);\n            \n            return count;\n           \n    }\n    \n    // dfs traversal \n    public void dfs( List<List<int[]>> graph, int vtx, boolean [] visited)\n    {\n         List<int[]> list = graph.get(vtx);\n         for(int [] pair : list)\n         {\n             if(visited[pair[0]]== false)\n             {\n                 visited[pair[0]] = true;\n                 // during dfs if we get the pair direction as 1 then it was original edge pointing away from 0\n                 // hence we increase the count as we would need to reverse it to reach 0 node\n                 if(pair[1] == 1)\n                 {\n                     count++;\n                 }\n                 dfs(graph, pair[0], visited);\n             }\n         }\n    }\n}
['Depth-First Search', 'Java']