[Python3] Easy Short DFS
Start from node 0 (the capital) and dfs on the path and see if the path is \nin the same direction as the traversal. If it is on the same direction that \nmeans
Start from `node 0` (the capital) and dfs on the path and see if the path is \nin the same direction as the traversal. If it is on the same direction that \nmeans we need to reverse it because it can never get to the capital.\n\n```\nclass Solution:\n    def minReorder(self, n: int, connections: List[List[int]]) -> int:\n        self.res = 0    \n        roads = set()\n        graph = collections.defaultdict(list)\n        for u, v in connections:\n            roads.add((u, v))\n            graph[v].append(u)\n            graph[u].append(v)\n        def dfs(u, parent):\n            self.res += (parent, u) in roads\n            for v in graph[u]:\n                if v == parent:\n                    continue\n                dfs(v, u)    \n        dfs(0, -1)\n        return self.res\n```\nDon\'t forget to upvote if you found this useful. Thank you.
[]