Advertisement
rajeshinternshala

Untitled

Oct 15th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1.  def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int:
  2.         # count frequency of characters
  3.         count = collections.Counter()
  4.        
  5.         # Check only for minSize
  6.         for i in range(len(s) - minSize + 1):
  7.             t = s[i : i+minSize]
  8.             if len(set(t)) <= maxLetters:
  9.                 count[t] += 1
  10.        
  11.         return max(count.values()) if count else 0
  12.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement