✅✅Faster || Easy To Understand || C++ Code
Time Complexity : O(N * constant)\n\n Time Complexity : O(1)*\n\n\nclass Solution {\npublic:\n    \n    int uniqueLetterString(string str) {\n        \n        
* ***Time Complexity : O(N * constant)***\n\n* ***Time Complexity : O(1)***\n\n```\nclass Solution {\npublic:\n    \n    int uniqueLetterString(string str) {\n        \n        int n = str.size();\n        \n        int ans = 0;\n        \n        for(char ch = \'A\'; ch <= \'Z\'; ch++)\n        {\n            int count = 0;\n            \n            int prev = -1;\n            \n            int pos = -1;\n            \n            for(int i = 0; i < n; i++)\n            {\n                if(str[i] == ch)\n                {\n                    count++;\n                    \n                    prev = pos;\n                    \n                    pos = i;\n                }\n                \n                if(count == 1)\n                {\n                    ans += pos + 1;\n                }\n                else\n                {\n                    ans += pos - prev;\n                }\n            }\n        }\n        \n        return ans;    \n    }\n};\n```
['C']