Javascript - Trie Solution (*can be further optimised)
Code\n\n/**\n * @param {string[][]} paths\n * @return {string[][]}\n */\n //create tree\n //mark duplicates\n //return non duplicates\nclass Node {\n    constru
# Code\n```\n/**\n * @param {string[][]} paths\n * @return {string[][]}\n */\n //create tree\n //mark duplicates\n //return non duplicates\nclass Node {\n    constructor(value) {\n        this.val = value || "";\n        this.children = {};\n        this.dirStr = "";\n    }\n}\n\nclass Trie {\n    constructor() {\n        this.root = new Node();\n    }\n    add(path) {\n        let node = this.root;\n        for (let p of path) {\n            if (!node.children[p]) {\n                node.children[p] = new Node(p);\n            } \n            node = node.children[p];    \n        }\n    }\n    dfs = function(node, duplicatesStr) {\n        let dirStr = [];\n        if (node) {\n            for (let child of Object.keys(node.children)) {\n                let subTree = this.dfs(node.children[child], duplicatesStr);\n                if (duplicatesStr[subTree] == undefined) {\n                    duplicatesStr[subTree] = false;\n                } else {\n                    duplicatesStr[subTree] = true;\n                }\n                \n                dirStr.push([...subTree].sort().join("") + node.children[child].val);\n            }\n            \n        }\n        dirStr.sort();\n        node.dirStr = dirStr.toString(); \n        return node.dirStr;\n    }\n\n    removeDuplicateDFS = function(node, duplicatesStr) {\n        if (node) {\n            for (let child of Object.keys(node.children)) {\n                this.removeDuplicateDFS(node.children[child], duplicatesStr);\n                if (duplicatesStr[node.children[child].dirStr] == true) {\n                    delete node.children[child];\n                }\n            }    \n        }\n    }\n\n    print(node, ans, stack) {\n        if (node.val != "") {\n            stack.push(node.val);\n            ans.push([...stack]);\n        }\n        for (let child of Object.keys(node.children)) {\n            this.print(node.children[child], ans, stack);\n        }\n        stack.pop();\n    }\n}\n\nvar deleteDuplicateFolder = function(paths) {\n    let trie = new Trie();\n    //create tree\n    for (let path of paths) {\n        trie.add(path);\n    }\n    //get directoryStructure and mark duplicates\n    let duplicatesStr = {}\n    trie.dfs(trie.root, duplicatesStr);\n    //remove duplicates\n    delete duplicatesStr[\'\'];\n    //console.log(duplicatesStr);\n    trie.removeDuplicateDFS(trie.root, duplicatesStr);\n    //console.log(JSON.stringify(trie))\n    //parse trie\n    let ans = [];\n    trie.print(trie.root, ans, []);\n    return ans;\n};\n```
['Depth-First Search', 'Trie', 'JavaScript']