(C++) 828. Count Unique Characters of All Substrings of a Given String
\n\nclass Solution {\npublic:\n    int uniqueLetterString(string s) {\n        vector<vector<int>> locs(26, vector<int>(1, -1)); \n        for (int i = 0; i < s
\n```\nclass Solution {\npublic:\n    int uniqueLetterString(string s) {\n        vector<vector<int>> locs(26, vector<int>(1, -1)); \n        for (int i = 0; i < s.size(); ++i) locs[s[i] - \'A\'].push_back(i); \n        \n        int ans = 0; \n        for (int i = 0; i < 26; ++i) {\n            locs[i].push_back(s.size()); \n            for (int k = 1; k < locs[i].size()-1; ++k) \n                ans += (locs[i][k] - locs[i][k-1]) * (locs[i][k+1] - locs[i][k]); \n        }\n        return ans; \n    }\n};\n```
['C']