打卡记录 统计子串中的唯一字符(找规律) 链接 大佬的题解 class Solution: def uniqueLetterString(self, s: str) -> int: ans = total = 0 last0, last1 = {}, {} for i, c in enumerate(s): total += i - 2 * last0.get(c, -1) + last1.get(c, -1) ans += total last1[c] = last0.get(c, -1) last0[c] = i return ans