C++ || Trie || DFS || Map || (TLE/MLE)
\nclass Solution {\nprivate:\n    map<string, int> cnt;\n    \n    struct Node {\n        string data;\n        string directory;\n        map<string, Node*> ne
```\nclass Solution {\nprivate:\n    map<string, int> cnt;\n    \n    struct Node {\n        string data;\n        string directory;\n        map<string, Node*> next;\n        Node(string value) {\n            data = value;\n            directory = "";\n        }\n    };\n    \n    void make_directory(Node* root, vector<vector<string>> &ans, vector<string> &path) {\n        if(root == NULL)\n            return;\n        else if(root->directory == "X")\n            return;\n        path.push_back(root->data);\n        ans.push_back(vector<string>(path));\n        for(auto it: root->next) {\n            if(it.second->directory != "X") {\n                make_directory(it.second, ans, path);\n                path.pop_back();\n            }\n        } \n    }\n    \n    void remove_duplicates(Node* root) {\n        if(root == NULL) \n            return;\n        if(cnt[root->directory] > 1) {\n            // value X determines it wouldn\'t be included\n           // cout << cnt[root->directory] << "-" << root->directory << endl;\n            root->directory = "X";\n        }\n        for(auto it: root->next) {\n            remove_duplicates(it.second);\n        }\n    }\n    \n    string mark_duplicates(Node* root) {\n        if(root == NULL)\n            return "X";\n        string directory = "";\n        for(auto it: root->next) {\n            directory = directory + mark_duplicates(it.second);\n\t\t\t// note: used ordered map\n            // why this line is added?? see the given testcase\n            directory += "/";\n        }\n        root->directory = directory;\n        if(directory.length() > 0)\n            cnt[directory] += 1;\n        return root->data + "/" + directory;\n    }\n    \n    void create_tree(Node* root, vector<string> &path) {\n        Node* curr = root;\n        for(string name: path) {\n            Node* node = curr->next[name];\n            if(node == NULL) {\n                node = new Node(name);\n                curr->next[name] = node;\n            }\n            curr = node;\n        }\n    }\n    \n    \npublic:\n    vector<vector<string>> deleteDuplicateFolder(vector<vector<string>>& paths) {\n        Node* root = new Node("/");\n        for(vector<string> path: paths)\n            create_tree(root, path);\n        \n        mark_duplicates(root);\n        remove_duplicates(root);\n        \n        vector<vector<string>> ans;\n        vector<string> path;\n        for(auto it: root->next) {\n            make_directory(it.second, ans, path);\n            path.clear();\n        }\n        \n        return ans;\n    }\n    \n    // ambiguity of this testcase while using ordered map\n    // [["a"],["a","c"],["a","d"],["a","d","e"],["b"],["b","e"],["b","c"],["b","c","d"],["f"],["f","h"],["f","h","i"],["f","j"],["g"],["g","j"],["g","h"],["g","h","i"]]\n};\n```
['Depth-First Search', 'Trie', 'C']