Trie again
Intuition\n Describe your first thoughts on how to solve this problem. \nUse Trie with memeber variable len\n# Approach\n Describe your approach to solving the 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse Trie with memeber variable len\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Define Trie struct with construtor, insert methods.\n2. In solution, let `trie` be the memeber variable.\n3. Define a member method `int score(const string& s)` to compute the score for `s`\n4. In `sumPrefixScores(vector<string>& words)`, add every s in word to the object `trie`.\n5. Use a loop to compute `ans[i]=score(words[i])`\n6. `ans` is the answer\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$O(\\sum_{s: words}|s|)$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$O(\\sum_{s: words}|s|)$\n# Code\n```cpp []\n// struct Trie for N alphabets\nconst int N=26;\nstruct Trie {\n    Trie* next[N];\n    int len=0;\n\n    Trie() {\n        memset(next, 0, sizeof(next));\n    }\n/*\n    ~Trie() {\n    //    cout<<"Destructor\\n";\n        for (int i=0; i<N; ++i) {\n            if (next[i] !=NULL) {\n                delete next[i];\n                next[i]=NULL;\n            }\n        }\n    }\n*/\n    void insert(const string& word) {\n        Trie* Node=this;\n        for(char c: word){\n            int i=c-\'a\';\n            if(Node->next[i]==NULL)\n                Node->next[i]=new Trie();\n            Node=Node->next[i];\n            Node->len++;\n        }\n    }\n};\nclass Solution {\npublic:\n    Trie trie;\n    inline int score(const string& s){\n        Trie* Node=&trie;\n        int cnt=0;\n        for(char c: s){\n            int i=c-\'a\';\n            Node=Node->next[i];\n            cnt+=Node->len;\n        }\n        return cnt;\n    }\n    vector<int> sumPrefixScores(vector<string>& words) {\n        int n=words.size();\n        for(string& s: words) trie.insert(s);\n        vector<int> ans(n);\n        for(int i=0; i<n; i++) \n            ans[i]=score(words[i]);\n        return ans;\n    }\n};\n\n\nauto init = []() {\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    cout.tie(nullptr);\n    return \'c\';\n}();\n```\n# Trie is an advanced data structure. Using it one can solve many problems\n[[Leetcode 140. Word Break II](https://leetcode.com/problems/word-break-ii/solutions/5203799/dp-hash-vs-dp-trie-0ms-beats-100/) Please turn on English subtitles if necessary]\n[https://youtu.be/_E-fcmVmkYU?si=Ve6Z8zuPIi08k0VI](https://youtu.be/_E-fcmVmkYU?si=Ve6Z8zuPIi08k0VI)
['Array', 'String', 'Trie', 'Counting', 'C++']