Python:  TLE  >>>  Faster than 99%  ||  Trie  || Optimization
For those who are encountering TLE, add some more check conditions\n While inserting words in the Trie, keep the max length of all the words.\n While searching 
For those who are encountering TLE, add some more check conditions\n* While inserting words in the Trie, keep the max length of all the words.\n* While searching in the Trie, if length of the word to be searched is greater than max length, return False.\n\n**Python Code:**\n\n```\nclass TrieNode:\n    def __init__(self):\n        self.links = {}\n        self.end = False\n    \nclass WordDictionary:\n\n    def __init__(self):\n        self.root = TrieNode()\n        self.maxL = 0   #store the maximum length of all the words inserted\n        \n    def addWord(self, word):\n        """\n        :type word: str\n        :rtype: None\n        """\n        node = self.root\n        l = 0\n        for w in word:\n            if w not in node.links:\n                node.links[w] = TrieNode()\n            node = node.links[w]\n            l += 1\n        \n        self.maxL = max(self.maxL, l)\n        node.end = True\n\n    def search(self, word):\n        """\n        :type word: str\n        :rtype: bool\n        """\n        if len(word) > self.maxL:    #optimization\n            return False\n        \n        def helper(index, node):\n            for inn in range(index, len(word)):\n                c = word[inn]\n                if c == ".":\n                    for child in node.links.values():\n                        if helper(inn+1, child):\n                            return True\n                    return False\n                else:\n                    if c not in node.links:\n                        return False\n                    node = node.links[c]\n\n            return node.end\n        return helper(0, self.root)\n```
['Python', 'Python3']