JAVA || Trie || Clean code
\nclass MagicDictionary {\n    class TrieNode {\n        Map<Character, TrieNode> children;\n        boolean endOfWord;\n        public TrieNode() {\n          
```\nclass MagicDictionary {\n    class TrieNode {\n        Map<Character, TrieNode> children;\n        boolean endOfWord;\n        public TrieNode() {\n            children = new HashMap<>();\n            endOfWord = false;\n        }\n    }\n    \n    //Insert by iteration\n    public void insert(TrieNode root, String word) {\n        TrieNode curr = root;\n        \n        for(char ch: word.toCharArray()) {\n            TrieNode node = curr.children.get(ch);\n            if(node == null) {\n                node = new TrieNode();\n                curr.children.put(ch, node);\n            }\n            curr = node;\n        }\n        \n        curr.endOfWord = true;\n    }\n    \n    //Search by iteration\n    public boolean searchHelper(TrieNode root, String word) {\n        TrieNode curr = root;\n        \n        for(char ch: word.toCharArray()) {\n            TrieNode node = curr.children.get(ch);\n            if(node == null) {\n                return false;\n            }\n            curr = node;\n        }\n        \n        return curr.endOfWord;\n    }\n\n    /** Initialize your data structure here. */\n    public TrieNode root;\n    public MagicDictionary() {\n        root = new TrieNode();\n    }\n    \n    public void buildDict(String[] dictionary) {\n        for(String word: dictionary) {\n            insert(root, word);\n        }\n    }\n    \n    public boolean search(String searchWord) {\n        TrieNode curr = root;\n        \n        int count = 0;\n        char[] word = searchWord.toCharArray();\n        for(int i = 0; i < word.length; i++) {\n            if(curr == null) {\n                return false;\n            }\n            \n            TrieNode node = curr.children.get(word[i]);\n            char org = word[i];\n            for(char ch: curr.children.keySet()) {\n                if(ch == org) continue;\n                \n                word[i] = ch;\n                if(searchHelper(root, new String(word))) {\n                    return true;\n                }\n            }\n            word[i] = org;\n            curr = node;\n        }\n        \n        return false;\n    }\n}\n\n/**\n * Your MagicDictionary object will be instantiated and called as such:\n * MagicDictionary obj = new MagicDictionary();\n * obj.buildDict(dictionary);\n * boolean param_2 = obj.search(searchWord);\n */\n```
['Trie', 'Java']