Reorder Nodes
\n/**\n * @param {number} n\n * @param {number[][]} connections\n * @return {number}\n */\nvar minReorder = function(n, connections) {\n    let visitSet = new S
```\n/**\n * @param {number} n\n * @param {number[][]} connections\n * @return {number}\n */\nvar minReorder = function(n, connections) {\n    let visitSet = new Set();\n    let count = 0;\n    let neighbours = new Map();\n    let edges = new Set();\n    for(let i=0;i<n;i++){\n        neighbours[i] = [];\n    }\n    \n    for(let [n1,n2] of connections){\n        neighbours[n1].push(n2);\n        neighbours[n2].push(n1);\n        edges.add(`${n1}.${n2}`)\n    }\n    \n    console.log(\'edges\',edges);\n    \n    const dfs = city => {\n        for(let neighbour of neighbours[city]){\n            if(visitSet.has(neighbour))\n                continue;\n            if(!edges.has(`${neighbour}.${city}`)){\n                console.log(`${neighbour}.${city}`);\n                count++;\n            }\n            visitSet.add(neighbour);\n            dfs(neighbour);\n        }\n    }\n    visitSet.add(0);\n    dfs(0);\n    return count;\n};\n```
['Depth-First Search', 'JavaScript']