题解 | #长度为 K 的重复字符子串#
长度为 K 的重复字符子串
https://www.nowcoder.com/practice/eced9a8a4b6c42b79c95ae5625e1d5fd
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param s string字符串
# @param k int整型
# @return int整型
#
class Solution:
def numKLenSubstrRepeats(self , s , k ):
# write code here
l=[c for c in s]
ans = 0
if k == len(s):
if len(l) == len(set(l)):
return True
else:
return False
for i in range(len(l)):
if i + k > len(l):
break
else:
if len(l[i:i+k]) == len(set(l[i:i+k])):
continue
else:
ans+=1
return ans
顺丰集团工作强度 335人发布