3335. 字符串转换后的长度 I
class Solution:def lengthAfterTransformations(self, s: str, t: int) -> int:# 大质数mod = 10**9+7# 创建一个长度为26的数组cnt,对应26个小写字母cnt = [0]*26# 计算出s中26个字符分别有多少个for ch in s:cnt[ord(ch)-ord('a')] +=1for round in range(t):nxt = [0]*26# a的个数nxt[0] = cnt[25]# b的个数nxt[1] = (cnt[25] + cnt[0]) % mod# 其他字符for i in range(2,26):nxt[i] = cnt[i-1]cnt = nxtans = sum(cnt)%modreturn ans