[Javascript] Simple understandable code with 100% memory
\nclass UnionFind {\n    constructor(n) {\n        this.parents = [];\n        for(let i = 0; i < n; i++) {\n            this.parents.push(i);\n        }\n     
```\nclass UnionFind {\n    constructor(n) {\n        this.parents = [];\n        for(let i = 0; i < n; i++) {\n            this.parents.push(i);\n        }\n        this.count = n;\n    }\n\n    find(index) {\n        const parent = this.parents[index];\n        if(parent === index) return index;\n\n        let root = this.find(parent);\n        this.parents[index] = root;\n        return root;\n    }\n\n    union(index1, index2) {\n        let p1 = this.find(index1);\n        let p2 = this.find(index2);\n\n        if(p1 !== p2) {\n            this.count--;\n            this.parents[p1] = p2;\n            return true;\n        }\n\n        return false;\n    }\n}\n\nvar findCriticalAndPseudoCriticalEdges = function(n, edges) {\n    let criticalEdges = [], psuedoCriticalEdges = [], map = new Map();\n    \n    edges.forEach((edge, i) => map.set(edge, i));\n    \n    edges.sort((a, b) => a[2] - b[2]);\n    \n    const buildMST = (pick, skip) => {\n        let uf = new UnionFind(n), cost = 0;\n        \n        if(pick !== null) {\n            uf.union(pick[0], pick[1]);\n            cost += pick[2];\n        }\n        \n        for(let edge of edges) {\n            if(edge !== skip && uf.union(edge[0], edge[1])) {\n                cost += edge[2];\n            }\n        }\n        \n        return uf.count === 1 ? cost : Number.MAX_SAFE_INTEGER;\n    };\n    \n    const minCost = buildMST(null, null);\n    \n    for(let edge of edges) {\n        const index = map.get(edge);\n        const costWithout = buildMST(null, edge);\n        if(costWithout > minCost) {\n            criticalEdges.push(index);\n        } else {\n            const costWith = buildMST(edge, null);\n            if(costWith === minCost) psuedoCriticalEdges.push(index);\n        }\n    }\n    \n    return [criticalEdges, psuedoCriticalEdges];\n};\n```\nThis solution is converted to javascript from Java solution posted by luo122174088. Suggestions are welcome for further optimizations.
['Union Find', 'JavaScript']