python O(n) - same approach with clean code
Other guys explained very well.\nI just wanted to try to write cleaner code (at least for me :) )\n\n\nclass Solution:\n  def uniqueLetterString(self, s):\n    
Other guys explained very well.\nI just wanted to try to write cleaner code (at least for me :) )\n\n```\nclass Solution:\n  def uniqueLetterString(self, s):\n    n, res = len(s), 0\n    indices_dict = defaultdict(lambda: [-1])\n    \n    for i, ch in enumerate(s):\n      indices_dict[ch].append(i)\n      \n    res = 0\n    for indices in indices_dict.values():\n      indices.append(n)\n      \n      for i in range(1, len(indices) - 1):\n        l = indices[i] - indices[i - 1]\n        r = indices[i + 1] - indices[i]\n        res += l * r\n        \n    return res\n        \n        \n```
[]