Easy to read O(N)
\nclass Solution:\n    def uniqueLetterString(self, s: str) -> int:\n        prev = ans = 0\n        d = {}\n        for i,c in enumerate(s):\n            k, j 
```\nclass Solution:\n    def uniqueLetterString(self, s: str) -> int:\n        prev = ans = 0\n        d = {}\n        for i,c in enumerate(s):\n            k, j = d.get(c,[-1,-1])\n            prev = prev + (i - j) - (j - k)\n            d[c] = [j,i]\n            ans += prev\n        return ans\n```
['Python3']