2
def uniqueLetterString(self, s: str) -> int:4
idx_recorder = collections.defaultdict(list)7
# record the index for every character14
for idx in range(len(s)):16
idx_recorder[c].append(idx)21
for i in range(len(idxes)):22
# Count the number of substring which contain the character without duplicating23
# get the left, right value to compute the result.25
# Take the middle A (idx=3) as example31
# The number of substring which contain this A (idx=3) without containing32
# other A is 3 * 4 = 1235
# If it is a first one: it means that there is36
# no duplicate character in left39
left = idxes[i] - idxes[i - 1]41
if i == len(idxes) - 1:42
# If it is a last one: it means that there is43
# no duplicate character in right side46
right = idxes[i + 1] - idxes[i]53
for c in idx_recorder:54
ans += helper(idx_recorder[c])