C# | Runtime beats 100.00%, Memory beats 53.06% [EXPLAINED]
Intuition\nTo find critical connections in a network (also known as bridges), we need to identify connections that, if removed, would disrupt the network\u2019s
# Intuition\nTo find critical connections in a network (also known as bridges), we need to identify connections that, if removed, would disrupt the network\u2019s connectivity. These connections are crucial because they connect different parts of the network in such a way that removing them would isolate some nodes.\n\n# Approach\nGraph Representation: First, represent the network using an adjacency list, where each node points to its neighbors.\n\nDFS Traversal: Use Depth-First Search (DFS) to explore the network. While exploring:\n\nTrack the discovery time of each node.\nTrack the lowest discovery time reachable from each node.\nAn edge is a bridge if there\u2019s no other path to reach its destination node from its subtree.\nUpdate and Check: During DFS, update the lowest discovery times and check if an edge meets the bridge criteria.\n\n# Complexity\n- Time complexity:\nO(V+E), where V is the number of vertices and E is the number of edges. This is because each node and edge is processed once.\n\n- Space complexity:\nO(V + E), for storing the graph and auxiliary arrays used in the DFS.\n\n# Code\n```csharp []\npublic class Solution\n{\n    private List<int>[] graph;\n    private int[] discovery;\n    private int[] low;\n    private bool[] visited;\n    private List<IList<int>> bridges;\n    private int time;\n\n    public IList<IList<int>> CriticalConnections(int n, IList<IList<int>> connections)\n    {\n        // Initialize data structures\n        graph = new List<int>[n];\n        for (int i = 0; i < n; i++)\n            graph[i] = new List<int>();\n\n        discovery = new int[n];\n        low = new int[n];\n        visited = new bool[n];\n        bridges = new List<IList<int>>();\n        time = 0;\n\n        // Build the graph\n        foreach (var conn in connections)\n        {\n            int u = conn[0];\n            int v = conn[1];\n            graph[u].Add(v);\n            graph[v].Add(u);\n        }\n\n        // Perform DFS from each node\n        for (int i = 0; i < n; i++)\n        {\n            if (!visited[i])\n            {\n                DFS(i, -1);\n            }\n        }\n\n        return bridges;\n    }\n\n    private void DFS(int u, int parent)\n    {\n        visited[u] = true;\n        discovery[u] = low[u] = ++time;\n\n        foreach (var v in graph[u])\n        {\n            if (v == parent) continue; // Skip the edge to the parent node\n\n            if (!visited[v])\n            {\n                DFS(v, u);\n\n                // Check if the subtree rooted at v has a connection back to an ancestor of u\n                low[u] = Math.Min(low[u], low[v]);\n\n                // If the lowest vertex reachable from subtree under v is below u in DFS tree, then u-v is a bridge\n                if (low[v] > discovery[u])\n                {\n                    bridges.Add(new List<int> { u, v });\n                }\n            }\n            else\n            {\n                // Update low value of u for parent function calls\n                low[u] = Math.Min(low[u], discovery[v]);\n            }\n        }\n    }\n}\n\n```
['C#']