Easy with Trie
\nclass TrieNode{\n  constructor(){\n    this.ch = {};\n    this.score = 0;\n  }\n}\n\nclass Trie{\n  constructor(){\n    this.root = new TrieNode();\n  }\n  ad
```\nclass TrieNode{\n  constructor(){\n    this.ch = {};\n    this.score = 0;\n  }\n}\n\nclass Trie{\n  constructor(){\n    this.root = new TrieNode();\n  }\n  add(word){\n    let cur = this.root;\n    for(let c of word){\n      if (!cur.ch.hasOwnProperty(c)){\n        cur.ch[c] = new TrieNode();\n      }\n      cur = cur.ch[c];\n      cur.score += 1;\n    }\n  }\n  get_score(word){\n    let cur = this.root;\n    let tot = 0;\n    for(let c of word){\n      if (!cur.ch.hasOwnProperty(c)){\n        break;\n      }\n      cur = cur.ch[c];\n      tot += cur.score;\n    }\n    return tot;\n  }\n}\n\nvar sumPrefixScores = function(words) {\n\n  let s = words;\n  let tree = new Trie();\n  let ans = [];\n  for(let w of s){\n    tree.add(w)\n  }\n  for(let w of words){\n    ans.push(tree.get_score(w));\n  }\n  return ans;\n};\n```\n# PlEASE UPVOTE!
['Trie', 'JavaScript']