⚙ C++ || NO TRIE || NLOGN SOLUTION
\t\tclass Solution {\n\t\tpublic:\n\t\t\tvector sumPrefixScores(vector& words) {\n\t\t\t\tint n = words.size();\n\t\t\t\tvector> words2;\n\t\t\t\tfor (int i = 0
\t\tclass Solution {\n\t\tpublic:\n\t\t\tvector<int> sumPrefixScores(vector<string>& words) {\n\t\t\t\tint n = words.size();\n\t\t\t\tvector<pair<string, int>> words2;\n\t\t\t\tfor (int i = 0; i < n; ++i) {\n\t\t\t\t\twords2.push_back(make_pair(words[i], i));\n\t\t\t\t}\n\t\t\t\tsort(words2.begin(), words2.end());\n\n\t\t\t\tvector<int> perm(n);\n\t\t\t\tfor (int i = 0; i < n; ++i) {\n\t\t\t\t\tperm[i] = words2[i].second;\n\t\t\t\t}\n\t\t\t\tvector<int> commonPrefix(n);\n\n\t\t\t\tfor (int i = 1; i < n; ++i) {\n\t\t\t\t\tstring const& w1 = words2[i - 1].first;\n\t\t\t\t\tstring const& w2 = words2[i].first;\n\t\t\t\t\tint l = min(w1.size(), w2.size());\n\t\t\t\t\tint p = 0;\n\t\t\t\t\twhile (p < l && w1[p] == w2[p]) {\n\t\t\t\t\t\t++p;\n\t\t\t\t\t}\n\t\t\t\t\tcommonPrefix[i] = p;\n\t\t\t\t}\n\n\t\t\t\tvector<int> ret(n);\n\t\t\t\tfor (int i = 0; i < n; ++i) {\n\t\t\t\t\tint prefix = words2[i].first.size();\n\t\t\t\t\tret[perm[i]] += prefix;\n\t\t\t\t\tfor (int j = i + 1; j < n; ++j) {\n\t\t\t\t\t\tprefix = min(prefix, commonPrefix[j]);\n\t\t\t\t\t\tif (prefix == 0) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tret[perm[i]] += prefix;\n\t\t\t\t\t\tret[perm[j]] += prefix;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t};
['Trie', 'C', 'C++', 'Java']