💡JavaScript Solution w/ Comments (Tarjan)
The idea\nApply tarjan\'s algorithms and be careful about a couple things:\n1. Since it\'s an undirected graph, we need to avoid going back to the same node\n2.
### The idea\nApply tarjan\'s algorithms and be careful about a couple things:\n1. Since it\'s an undirected graph, we need to avoid going back to the same node\n2. When dfs finishes, propagate the low-value during the call stack (backtracking)\n3. When `to` node is visited, it may have a lower `id` than current low-value\n[This](https://www.youtube.com/watch?v=aZXi1unBdJA&t=503s) and [this](chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=(1)%20Tarjans%20Strongly%20Connected%20Components%20algorithm%20%7C%20Graph%20Theory%20-%20YouTube&pos=0&uri=https://www.youtube.com/watch?v=TyWtx7q2D7Y&t=841s) are extremely helpful tutorials.\n``` javascript\n/**\n * @param {number} n\n * @param {number[][]} connections\n * @return {number[][]}\n */\nvar criticalConnections = function(n, connections) {\n    let graph = [];\n    // generate graph using adjuacency list\n    for ([from, to] of connections) {\n        if (!graph[from]) graph[from] = [];\n        if (!graph[to]) graph[to] = [];\n        graph[from].push(to);\n        graph[to].push(from)\n    }\n\n    let id = 0;\n    let ids = new Array(n).fill(0); // id for each node\n    let lows = new Array(n).fill(0); // low - value\n    let visited = new Array(n).fill(false);\n    let bridges = [];\n\n    var dfs = function(at, prev) {\n        visited[at] = true;\n        id++;\n        lows[at] = ids[at] = id;\n\n        for (let to of graph[at]) {\n            if (to == prev) continue; // sanity check - in an undirected graph, an outward edge may come back right after\n            if (!visited[to]) {\n                dfs(to, at);\n                // during the backtracking, propagate min low-value\n                lows[at] = Math.min(lows[at], lows[to]);\n                if (ids[at] < lows[to]) { // bridge found\n                    bridges.push([at, to]);\n                }\n            } else {\n                // when the \'to\' node is already visited, it might have a lower id than our low-value\n                lows[at] = Math.min(lows[at], ids[to]);\n            }\n        }\n    }\n\n    for (let i=0;i<n;i++) {\n        if (!visited[i]) {\n            dfs(i, -1);\n        }\n    }\n\n    return bridges;\n};\n```
['JavaScript']