Trie [Count and fetch] | C++
C++\n    struct trie {\n       trie *child[26] = {};\n       int count=0;\n    }; \n    \n    vector sumPrefixScores(vector& A) {\n        trie td;\n        \n 
# C++\n    struct trie {\n       trie *child[26] = {};\n       int count=0;\n    }; \n    \n    vector<int> sumPrefixScores(vector<string>& A) {\n        trie td;\n        \n        //put all words\n        for(auto w:A){\n            //insert word in trie\n            auto root= &td;\n            for(auto j:w){\n                if(!root->child[j-\'a\']) root->child[j-\'a\']= new trie();\n                root= root->child[j-\'a\'];\n                root->count++;\n            }\n        }\n        \n        vector<int> ans;  ans.reserve(A.size());\n        \n        for(auto w:A){\n            auto root= &td;\n            int n=0;\n            for(auto j:w){\n                root= root->child[j-\'a\'];\n                //get count of prefix stored\n                n+= root->count;\n            }\n            ans.push_back(n);\n        }\n        \n        return ans;\n    }
['Trie', 'C']