C++ Sliding window sloution
\nclass Solution {\npublic:\n    /*\n        For each char str[i]..\n        Find it\'s previous and next occurrence (left and right vectors)..\n        Now thi
```\nclass Solution {\npublic:\n    /*\n        For each char str[i]..\n        Find it\'s previous and next occurrence (left and right vectors)..\n        Now this is the range where str[i] will be unique..\n        So total number of substrings where str[i] will be unique = left[i] * right[i]\n\n        NOTE: str[i] will be present in all (left[i] * right[i]) substrings because we are\n              calculating length of the substring while always considering \'i\', i.e. str[i].\n    */\n    int uniqueLetterString(string str) {        \n        int n = str.size();\n        vector<int> left(n,0), right(n,0);\n        int ans = 0;\n        \n        for(int i=0; i<n; i++) {\n            int j=i-1;\n            while(j>=0) {\n                if(str[j] == str[i]) break;\n                j--;\n            }\n            left[i] = i-j;\n            \n            j=i+1; ;\n            while(j<n) {\n                if(str[j] == str[i]) break;\n                j++;\n            }\n            right[i] = j-i;\n        }\n        \n        for(int i=0; i<n; i++) {\n            ans += (left[i] * right[i]);\n        }\n        \n        return ans;\n    }\n};\n```
['C', 'Sliding Window']