Python, Tries. Clean code.
\n"""\nTrieNode class : It is representation of each TrieNode.\n\nTrie class: It has related operations related to tries. (Note: The search is modified to handl
```\n"""\nTrieNode class : It is representation of each TrieNode.\n\nTrie class: It has related operations related to tries. (Note: The search is modified to handle the regex matching)\n\n"""\nfrom collections import defaultdict\n\nclass TrieNode:\n    def __init__(self):\n        self.children = defaultdict(list)\n        self.isWord = False\n\nclass Trie:\n    def __init__(self):\n        self.root = TrieNode()\n        \n    def insert(self, word):\n        root = self.root\n        for w in word:\n            if w not in root.children:\n                root.children[w] = TrieNode()\n            root = root.children[w]\n        root.isWord = True\n    \n    def search(self, root, word):\n        for i in range(len(word)):\n            if word[i] != \'.\':\n                if word[i] in root.children:\n                    root = root.children[word[i]]\n                else:\n                    return False\n            else:\n\t\t\t\t#If the present char is a \'.\' then I visit all the children nodes in DFS manner to find match\n                visitAll = root.children\n                for child in visitAll:\n                    if self.search(root.children[child], word[i+1:]):\n                        return True\n                return False\n        return (root.isWord == True)\n\n\nclass WordDictionary(object):\n    def __init__(self):\n        self.trie = Trie()\n        self.root = self.trie.root\n\n    def addWord(self, word):\n        self.trie.insert(word)\n    \n    def search(self, word):\n        return self.trie.search(self.root, word)\n        \n```
['Backtracking', 'Tree', 'Depth-First Search', 'Python']