C++ || TRIE || EASY TO UNDERSTAND || SHORT & SWEET CODE
\nclass trie{//make trie class\n    public:\n        int cnt;\n        trie* v[26];\n        trie(){\n            cnt = 0;//no of common prefix\n            for
````\nclass trie{//make trie class\n    public:\n        int cnt;\n        trie* v[26];\n        trie(){\n            cnt = 0;//no of common prefix\n            for(int i = 0; i < 26; i++){\n                v[i] = NULL;\n            }\n        }\n};\nclass Solution {\npublic:\n    vector<int> sumPrefixScores(vector<string>& words) {\n        trie *node = new trie(),*tmp;//inittilize trie root node\n        for(auto &i: words){\n            tmp = node;\n            for(auto &j: i){\n                if(tmp->v[j-\'a\']==NULL){//if node not found make node\n                    tmp->v[j-\'a\'] = new trie();\n                    tmp = tmp->v[j-\'a\'];\n                    tmp->cnt++;\n                }else{//if node found\n                    tmp = tmp->v[j-\'a\'];\n                    tmp->cnt++;//increment prefix count by one\n                }\n            }\n        }\n        int sum = 0;\n        vector<int> ans;\n        for(auto &i: words){\n            sum = 0;// for string i ans = 0\n            tmp = node;\n            for(auto &j: i){\n                sum += (tmp->v[j-\'a\'])->cnt;//add no of common prefix\n                tmp = tmp->v[j-\'a\'];\n            }\n            ans.push_back(sum);\n        }\n        return ans;\n    }\n};\n````
['Trie', 'C', 'C++']