Java Trie
\nclass MagicDictionary {\n    public class Node{\n        boolean isW;\n        Node[] nodes;\n        public Node() {\n            nodes = new Node[26];\n    
```\nclass MagicDictionary {\n    public class Node{\n        boolean isW;\n        Node[] nodes;\n        public Node() {\n            nodes = new Node[26];\n            isW = false;\n        }\n    }\n    \n    Node root;\n\n    /** Initialize your data structure here. */\n    public MagicDictionary() {\n        root = new Node();\n    }\n    \n    /** Build a dictionary through a list of words */\n    public void buildDict(String[] dict) {\n        for (String w : dict) {\n            Node curr = root;\n            for (char c : w.toCharArray()) {\n                if (curr.nodes[c - \'a\'] == null) {\n                    curr.nodes[c - \'a\'] = new Node();\n                }\n                curr = curr.nodes[c - \'a\'];\n            }\n            curr.isW = true;\n        }\n    }\n    \n    /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */\n    public boolean search(String word) {\n        char[] arr = word.toCharArray();\n        for (int i = 0; i < arr.length; i++) {\n            char c = arr[i];\n            for (int j = 0; j < 26; j++) {\n                if (j == (c - \'a\')) continue;\n                arr[i] = (char) (\'a\' + j);\n                if (isW(arr)) return true;\n            }\n            arr[i] = c;\n        }\n        return false;\n    }\n    \n    public boolean isW(char[] arr) {\n        Node curr = root;\n        for (char c : arr) {\n            if (curr.nodes[c - \'a\'] == null) {\n                return false;\n            }\n            curr = curr.nodes[c - \'a\'];\n        }\n        return curr.isW;\n    }\n}\n```
[]