from collections import defaultdict
class Solution:
def findSubstringInWraproundString(self, p: str) -> int:
dic = defaultdict(int)
dic[p[0]] = 1
tmp = 1
for i in range(1, len(p)):
if (ord(p[i]) - ord(p[i - 1])) % 26 == 1:
tmp = tmp + 1
else:
tmp = 1
dic[p[i]] = max(dic[p[i]], tmp)
return sum(dic.values())
**找出连续的字符串并记录长度,相邻的就加1,不相邻的变成1,最后就是以每个字母结尾的字符串的个数。重复字符注意 **