Just out of curiosity
Did anyone solve this problem without knowing the exisiting algorithm?\nI think this is quite unfriendly to the people who didnt have the perquisite knowledge.\
Did anyone solve this problem without knowing the exisiting algorithm?\nI think this is quite unfriendly to the people who didnt have the perquisite knowledge.\n\nAnyway, here is the solution:\n```\nclass Solution:\n    def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:\n        connect = collections.defaultdict(list)\n        for u,v in connections:\n            connect[u] += [v]\n            connect[v] += [u]\n        self.dep = 0\n        depth, lowest, parent, visited = [float("inf")]*n, [float("inf")]*n, [float("inf")]*n, [False]*n\n        self.res = []\n        def dfs(u):     \n            visited[u] = True\n            depth[u], lowest[u] = self.dep, self.dep\n            self.dep += 1\n            for v in connect[u]:   \n                if not visited[v]:\n                    parent[v] = u\n                    dfs(v)\n                    if lowest[v]>depth[u]:\n                        self.res += [[u,v]]\n                if parent[u]!=v:\n                    lowest[u] = min(lowest[u], lowest[v])\n        dfs(0)\n        return self.res\n```
[]