2083. Substrings That Begin and End With the Same Letter
On This Page
class Solution:
def numberOfSubstrings(self, s: str) -> int:
cnt = Counter()
res = 0
for c in s:
cnt[c] += 1
res += cnt[c]
return res