✔️ [Javascript] solution || Very simple
This is not my answer. I found it in this Github repository https://github.com/AnasImloul/Leetcode-solutions\nIt is very helpful, check it out.\n\nclass Node{\n
This is not my answer. I found it in this Github repository https://github.com/AnasImloul/Leetcode-solutions\nIt is very helpful, check it out.\n```\nclass Node{\n    constructor(val,parent){\n        this.val=val,this.parent=parent,this.children={},this.hash\n    }\n}\nclass Trie{\n    constructor(){\n        this.root=new Node(\'\')\n        this.hashMemo={}\n    }\n    insert(path){\n        let cur=this.root\n        for(let node of path )\n            if(cur.children[node]!==undefined)\n                cur=cur.children[node]\n            else\n                cur.children[node]=new Node(node,cur),\n                cur=cur.children[node]\n    }\n    traverse(node=this.root){\n        node.hash=[]\n        if(node.children)\n            for(let child of Object.values(node.children))\n                node.hash.push(this.traverse(child))\n        node.hash=node.hash.join(\'~\')\n        if(node.hash!==\'\'){\n            if(this.hashMemo[node.hash]===undefined)\n                this.hashMemo[node.hash]=[] \n            this.hashMemo[node.hash].push(node)\n            return node.val+\'/[\'+node.hash+\']\'\n        }\n        return node.val\n    }\n    delete(node=this.root){\n        if(!node || node.hash===undefined)\n            return\n        else if(this.hashMemo[node.hash] && this.hashMemo[node.hash].length>1)\n            for(let todelete of this.hashMemo[node.hash])\n                delete todelete.parent.children[todelete.val]\n        else\n            for(let child of Object.values(node.children))\n                this.delete(child)\n    }\n    serialize(node=this.root,stack=[],res=[]){\n        if(node.val!==\'\')\n            stack.push(node.val),\n            res.push([...stack])\n        for(let child of Object.values(node.children))\n            this.serialize(child,stack,res)\n        stack.pop()\n        return res\n    }\n}\n\nvar deleteDuplicateFolder = function(paths) {\n    let T=new Trie()\n    for(let P of paths)\n        T.insert(P)\n    T.traverse()\n    T.delete()\n    return T.serialize()\n};\n\n```
['JavaScript']