标签:def 出现 code src tco range let letters info
题目描述:
自己的提交:
class Solution: def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int: c = collections.Counter() for i in range(len(s)-minSize+1): if len(set(s[i:i+minSize])) <= maxLetters: c[s[i:i+minSize]] += 1 if not c: return 0 else: return max(v for i,v in c.items())
优化:
class Solution: def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int: c = collections.Counter() for i in range(len(s)-minSize+1): if len(set(s[i:i+minSize])) <= maxLetters: c[s[i:i+minSize]] += 1 return max(c.values(),default = 0)
标签:def 出现 code src tco range let letters info
原文地址:https://www.cnblogs.com/oldby/p/12097908.html