Python| Easy and fast | Beats 99%
Time complexity: O(n)\n\nShort description:\nIn this solution, we add cities one by one to the country map. This addition follows 3 rules:\n1)If the first city 
Time complexity: O(n)\n\nShort description:\nIn this solution, we add cities one by one to the country map. This addition follows 3 rules:\n1)If the first city of the road is already on the map, we need to change direction of this road and add a new city to the map.\n2)If the second city of  the road is already on the map,  we only add a new city to the map.\n3) If both cities are not on the map, we postpone this road and select next one. \n\nSolution:\n```\nclass Solution:\n    def minReorder(self, n: int, connections: List[List[int]]) -> int:\n        cmap = {0}\n        count = 0\n        dq = deque(connections)\n        while dq:\n            u, v = dq.popleft()\n            if v in cmap:\n                cmap.add(u)\n            elif u in cmap:\n                cmap.add(v)\n                count += 1\n            else:\n                dq.append([u, v])\n        return count\n            \n```
['Python', 'Python3']