[Python] Trie Solution
Explanation\nUse Trie to build up a tree.\nadd word and add 1 point to each node on the word path.\nsocre will sum up the point on the word path.\n\n\n# Complex
# **Explanation**\nUse Trie to build up a tree.\n`add` word and add `1` point to each node on the word path.\n`socre` will sum up the point on the word path.\n<br>\n\n# **Complexity**\nTime `O(words)`\nSpace `O(words)`\n<br>\n\n\n**Python**\n```py\nclass Trie(object):\n\n    def __init__(self):\n        T = lambda: defaultdict(T)\n        self.root = T()\n\n    def add(self, word):\n        node = self.root\n        for w in word:\n            node = node[w]\n            node[\'#\'] = node.get(\'#\', 0) + 1\n\n    def score(self, word):\n        res = 0\n        node = self.root\n        for w in word:\n            node = node[w]\n            res += node.get(\'#\', 0)\n        return res\n\nclass Solution(object):\n    def sumPrefixScores(self, words):\n        trie = Trie()\n        list(map(trie.add, words))\n        return list(map(trie.score, words))\n```\n
[]