Python | Tarjan's Algorithm | Beats 95%
\nclass Solution:\n    def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:\n        disc = [-1]*n\n        low = [-1]*n\n   
```\nclass Solution:\n    def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:\n        disc = [-1]*n\n        low = [-1]*n\n        \n        network = [[] for _ in range(n)]\n        for a, b in connections:\n            network[a].append(b)\n            network[b].append(a)\n        \n        def tarjan(prev, node, time, disc, low, network, ans):\n            if disc[node] != -1:\n                return disc[node]\n\n            disc[node] = time\n            low[node] = time\n            \n            for x in network[node]:\n                if x != prev:\n                    newLow = tarjan(node, x, time+1, disc, low, network, ans)\n                    low[node] = min(low[node], newLow)\n                    if low[x] > disc[node]:\n                        ans.append([x,node])\n                        \n            return low[node]\n        \n        ans = []\n        tarjan(0, 0, 0, disc, low, network, ans)\n        \n        return ans\n```
['Python']