python dfs (actually simple not like the cringe overly short solutions)
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:\n    def buildAdj(self, matrix, n):\n        adj = [[] for _ in range(n)]\n\n        for a,b in matrix:\n            adj[a].append((b, True))\n            adj[b].append((a, False))\n        \n        return adj\n\n    def minReorder(self, n: int, connections: List[List[int]]) -> int:\n        count = 0\n        adj = self.buildAdj(connections, n)\n        visit = set()\n\n        def dfs(node):\n            nonlocal count\n            visit.add(node)\n\n            for nei, outgoing in adj[node]:\n                if nei not in visit:\n                    if outgoing:\n                        count += 1\n                \n                    dfs(nei)\n                \n        dfs(0)\n        return count\n```
['Python3']