hash map by converting internal folder structures to strings
Approach\n- build nested dictionary structure\n- create sets/maps of structures found\n- filter for unique structures\n\n# Complexity\nN = number of folders\n\n
# Approach\n- build nested dictionary structure\n- create sets/maps of structures found\n- filter for unique structures\n\n# Complexity\nN = number of folders\n\n- Time complexity:\nbuild nested dictionary structure: O(N)\ncreate sets/maps of structures found: O(N * N)\nfilter for unique structures: O(N)\n__Overall: O(N*N)__\n- Space complexity:\nbuild nested dictionary structure: O(N)\ncreate sets/maps of structures found: O(N)\nfilter for unique structures: O(N)\n__Overall: O(N)__\n\n# Code\n```\n# get the inner structure of the folder recursively\ndef get_path(folder):\n    out = "/"\n\n    # sort required because different folders might have\n    # different order of subfolders\n    for key in sorted(folder.keys()):\n        out += key\n        out += get_path(folder[key])\n\n    out += ";"\n    return out\n\n# traverse a nested dictionary structure\ndef get_nested_item(itemarray, nested):\n    item = nested\n    for key in itemarray:\n        item = item[key]\n    return item\n\nclass Solution(object):\n    def deleteDuplicateFolder(self, paths):\n        """\n        :type paths: List[List[str]]\n        :rtype: List[List[str]]\n        """\n\n        # build nested dictionary representing folders\n        mapping = {}\n        for path in paths:\n            cur_folder = mapping\n            for folder in path:\n                cur_folder.setdefault(folder, {})\n                cur_folder = cur_folder[folder]\n\n        # the top level node is not in path but still\n        # needs to be present in the dict\n        internal_structure = {(): \'/;\'}\n        # could also be implemented using a dict and counting occurences\n        structures_found = set()\n        structures_multiple = set()\n\n        # create maps of structures found\n        for path in paths:\n            path_str = get_path(get_nested_item(path, mapping))\n            internal_structure[tuple(path)] = path_str\n            if path_str != \'/;\':\n                if path_str not in structures_found:\n                    structures_found.add(path_str)\n                elif path_str not in structures_multiple:\n                    structures_multiple.add(path_str)\n        \n        # only append those paths that are not present\n        remaining = []\n        for path in paths:\n            structure = internal_structure[tuple(path)]\n            if structure == \'/;\':\n                structure = internal_structure[tuple(path[:-1])]\n            if structure in structures_multiple:\n                pass\n            else:\n                remaining.append(path)\n\n        return remaining\n\n```
['Python']