Faster than 90% || Serialize Tree || Trie || Clean Java Code
Code\njava []\nclass TrieNode {\n    Map<String, TrieNode> children;\n    String hashValue = "";\n    boolean isEnd = false;\n\n    public TrieNode() {\n       
# Code\n```java []\nclass TrieNode {\n    Map<String, TrieNode> children;\n    String hashValue = "";\n    boolean isEnd = false;\n\n    public TrieNode() {\n        this.children = new HashMap<>();\n    }\n}\n\nclass Trie {\n    final TrieNode root = new TrieNode();\n    Map<String, Integer> hashFrequency = new HashMap<>();\n    List<List<String>> paths = new ArrayList<>();\n\n    public void insert(List<String> path) {\n        TrieNode curr = root;\n        for (String folder : path) {\n            curr = curr.children.computeIfAbsent(folder, _ -> new TrieNode());\n        }\n        curr.isEnd = true;\n    }\n\n    public String computeHashes(TrieNode node) {\n        if (node.children.isEmpty()) return "";\n\n        StringBuilder hashValue = new StringBuilder();\n        List<String> childHashes = new ArrayList<>();\n\n        for (String childKey : node.children.keySet()) {\n            childHashes.add(childKey + "," + computeHashes(node.children.get(childKey)));\n        }\n\n        Collections.sort(childHashes);\n        hashValue.append("(").append(String.join("", childHashes)).append(")");\n        node.hashValue = hashValue.toString();\n        hashFrequency.put(node.hashValue, hashFrequency.getOrDefault(node.hashValue, 0) + 1);\n\n        return node.hashValue;\n    }\n\n    public void generateUniquePaths(List<String> path) {\n        TrieNode curr = root;\n        for (String folder : path) {\n            TrieNode child = curr.children.get(folder);\n            if (!child.hashValue.isEmpty() && hashFrequency.get(child.hashValue) > 1) {\n                return;\n            }\n            curr = child;\n        }\n        paths.add(path);\n    }\n}\n\nclass Solution {\n    public List<List<String>> deleteDuplicateFolder(List<List<String>> paths) {\n        Trie trie = new Trie();\n        for (List<String> path : paths) {\n            trie.insert(path);\n        }\n        trie.computeHashes(trie.root);\n        for (List<String> path : paths) {\n            trie.generateUniquePaths(path);\n        }\n        return trie.paths;\n    }\n}\n```
['Array', 'Hash Table', 'String', 'Trie', 'Hash Function', 'Java']