[Java] Simple Trie solution
java\nclass MagicDictionary {\n    private final TrieNode root;\n\n    public MagicDictionary() {\n        this.root = new TrieNode();\n    }\n    \n    public 
```java\nclass MagicDictionary {\n    private final TrieNode root;\n\n    public MagicDictionary() {\n        this.root = new TrieNode();\n    }\n    \n    public void buildDict(final String[] dictionary) {\n        for(String word : dictionary)\n            this.buildDictHelper(this.root, word);\n    }\n\n    public void buildDictHelper(TrieNode root, final String word) {\n        for(int i = 0; i < word.length(); i++) {\n            final int index = word.charAt(i) - \'a\';\n\n            if(root.nextCharacters()[index] == null)\n                root.nextCharacters()[index] = new TrieNode();\n\n            root = root.nextCharacters()[index];\n        }\n        root.isWord(true);\n    }\n    \n    public boolean search(final String searchWord) {\n        return this.dfs(this.root, searchWord, 0, false);\n    }\n\n    public boolean dfs(final TrieNode root, final String searchWord, final int index, final boolean mismatch) {\n        if (index == searchWord.length()) \n            return (root.isWord() && index == searchWord.length() && mismatch);\n        \n        final int j = searchWord.charAt(index) - \'a\';\n\n        if (!mismatch) {\n            for (int i = 0; i < 26; i++) {\n                if (i == j || root.nextCharacters()[i] == null)\n                    continue;\n                if (dfs(root.nextCharacters()[i], searchWord, index + 1, true))\n                    return true;\n            }\n        }\n        if (root.nextCharacters()[j] != null && dfs(root.nextCharacters()[j], searchWord, index + 1, mismatch))\n            return true;\n        return false;\n    }\n\n    private final class TrieNode {\n        private final TrieNode[] nextCharacters;\n        private boolean isWord;\n\n        public TrieNode() {\n            this.nextCharacters = new TrieNode[26];\n            this.isWord = false;\n        }\n\n        public boolean isWord() {\n            return this.isWord;\n        }\n\n        public void isWord(final boolean isWord) {\n            this.isWord = isWord;\n        }\n\n        public TrieNode[] nextCharacters() {\n            return this.nextCharacters;\n        }\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```
['Java']