Easy logic code of C++ | few lines of Cpp code | Must Check it
@iprincekumark\nVISIT MY PROFILE\nCODE :\n\nint uniqueLetterString(string str) {\n        int i, count, prev, pos, n = str.size(), ans = 0;\n        for(char ch
# **[@iprincekumark](https://leetcode.com/iprincekumark/)**\nVISIT MY PROFILE\n**CODE :**\n```\nint uniqueLetterString(string str) {\n        int i, count, prev, pos, n = str.size(), ans = 0;\n        for(char ch = \'A\'; ch <= \'Z\'; ch++)\n        {\n            count = 0;\n            prev = -1;\n            pos = -1;\n            for(int i = 0; i < n; i++)\n            {\n                if(str[i] == ch)\n                {\n                    count++;\n                    prev = pos;\n                    pos = i;\n                }\n                if(count == 1)\n                    ans += pos + 1;\n                else\n                    ans += pos - prev;\n            }\n        }\n        return ans;    \n    }\n```
['Dynamic Programming', 'C', 'C++']