[JavaScript] Trie
\nclass TrieNode {\n    constructor() {\n        this.children = {};\n        this.cnt = 0;\n    }\n}\n\n\nvar sumPrefixScores = function(words) {\n    const ro
```\nclass TrieNode {\n    constructor() {\n        this.children = {};\n        this.cnt = 0;\n    }\n}\n\n\nvar sumPrefixScores = function(words) {\n    const root = new TrieNode();\n    function add(w) {\n        let cur = root;\n       for(let i = 0; i<w.length; i++){\n           const c = w[i];\n           if(!cur.children[c]) {\n               cur.children[c] = new TrieNode();\n           }\n           cur = cur.children[c];\n           cur.cnt++;\n       } \n    }\n    function find(w) {\n        let total = 0;\n        let cur = root;\n        for(let i = 0; i<w.length; i++){\n           const c = w[i];\n           if(!cur.children[c]) {\n               break;\n           }\n           cur = cur.children[c];\n           total += cur.cnt;\n       } \n        return total;\n    }\n    for(const word of words) {\n        add(word);\n    }\n    const ans = [];\n    for(const word of words) {\n        ans.push(find(word));\n    }\n    return ans;   \n};\n```
['Trie', 'JavaScript']