C++ | Trie Solution
cpp\nclass Node {\npublic:\n    char ch;\n    Node* children[26] = {nullptr};\n    int prefix_cnt;\n};\n\nclass Solution {\nprivate:\n    Node* root = new Node;
```cpp\nclass Node {\npublic:\n    char ch;\n    Node* children[26] = {nullptr};\n    int prefix_cnt;\n};\n\nclass Solution {\nprivate:\n    Node* root = new Node;\n    int prefixCount(string &prefix) {\n        Node* tmp = root;\n        int cnt = 0;\n        for (char &ch : prefix) {\n            int index = ch - \'a\';\n            if (tmp->children[index] == nullptr) break;\n            tmp = tmp->children[index];\n            cnt += tmp->prefix_cnt;\n        }\n        return cnt;\n    }\n    void insertWord(string &word) {\n        Node* ptr = root;\n        for (char &ch : word) {\n            if (ptr->children[ch - \'a\'] == nullptr)\n                ptr->children[ch - \'a\'] = new Node();\n            ptr = ptr->children[ch - \'a\'];\n            ptr->prefix_cnt++;\n        }\n    }\npublic:\n    vector<int> sumPrefixScores(vector<string>& words) {\n        vector<int> res;\n        for (string &word : words) insertWord(word);\n        for (string &word : words) {\n            int r = prefixCount(word);\n            res.push_back(r);\n        }\n        return res;\n    }\n};\n```
['Trie', 'C', 'C++']