Java with Map and Trie
I used Trie with Map as its children. Using DFS to search for the word and deal with the dot separately. This is a good question to practice Trie.\n\nclass Word
I used Trie with Map as its children. Using DFS to search for the word and deal with the dot separately. This is a good question to practice Trie.\n```\nclass WordDictionary {\n    class TrieNode{\n        Map<Character, TrieNode> children;\n        boolean isWord;\n        TrieNode() {\n            children = new HashMap<>();\n            isWord = false;\n        }\n    }\n\n    private TrieNode root;\n    /** Initialize your data structure here. */\n    public WordDictionary() {\n        root = new TrieNode();\n    }\n    \n    /** Adds a word into the data structure. */\n    public void addWord(String word) {\n        if (word == null || word.length() == 0) {\n            return;\n        }\n        TrieNode cur = root;\n        for (char c : word.toCharArray()) {\n            TrieNode next = cur.children.get(c);\n            if (next == null) {\n                next = new TrieNode();\n                cur.children.put(c, next);\n            }\n            cur = next;\n        }\n        cur.isWord = true;\n    }\n    \n    /** Returns if the word is in the data structure. A word could contain the dot character \'.\' to represent any one letter. */\n    public boolean search(String word) {\n        return search(word, 0, root);\n    }\n    \n    private boolean search(String word, int idx, TrieNode node) {\n        if (idx == word.length()) {\n            return node.isWord;\n        }\n        if (word.charAt(idx) == \'.\') {\n            for (char c : node.children.keySet()) {\n                if (search(word, idx + 1, node.children.get(c))) {\n                    return true;\n                }\n            }\n        }\n        else {\n            if (node.children.get(word.charAt(idx)) != null) {\n                return search(word, idx + 1, node.children.get(word.charAt(idx)));\n            }\n        }\n        return false;\n    }\n}\n\n/**\n * Your WordDictionary object will be instantiated and called as such:\n * WordDictionary obj = new WordDictionary();\n * obj.addWord(word);\n * boolean param_2 = obj.search(word);\n */\n```
['Depth-First Search', 'Trie', 'Java']