Python Brute Force. Interview Version. Time Limit Exceeded
I don\'t think I could come up with Tarjan\'s Algo on the spot in the interview. If this question was asked in the interview. Here\'s what I would write\n\nfrom
I don\'t think I could come up with Tarjan\'s Algo on the spot in the interview. If this question was asked in the interview. Here\'s what I would write\n```\nfrom collections import defaultdict\nclass Solution:\n    def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:\n        res = []\n        for removed_edge in connections:\n            graph = defaultdict(list)\n            for connection in connections:\n                if connection != removed_edge:\n                    graph[connection[0]].append(connection[1])\n                    graph[connection[1]].append(connection[0])\n            \n            seen = set()\n            stack = list()\n            stack.append(list(graph)[0])\n            while stack:\n                node = stack.pop()\n                seen.add(node)\n                for nei in graph[node]:\n                    if nei not in seen:\n                        seen.add(nei)\n                        stack.append(nei)\n            if len(seen)<n:\n                res.append(removed_edge)\n        return res\n```
[]