comefrom: <doocs>0395.Longest Substring with At Least K Repeating Characters_1.py
code: def longestSubstring( s: str, k: int) -> int:
      n = len(s)
      maxLength = 0
      
      for i in range(1, 27):
          counter = dict()
          left = 0
          right = 0
          unique = 0
          kCount = 0
      
          while right < n:
              if unique <= i:
                  r = s[right]
                  counter[r] = counter.get(r, 0) + 1
      
                  if counter[r] == 1:
                      unique += 1
                  if counter[r] == k:
                      kCount += 1
      
                  right += 1
      
              else:
                  l = s[left]
                  counter[l] = counter.get(l, 0) - 1
      
                  if counter[l] == 0:
                      unique -= 1
                  if counter[l] == k - 1:
                      kCount -= 1
      
                  left += 1
      
              if unique == i and kCount == i:
                  maxLength = max(maxLength, right - left)
      
      return maxLength
masked: def sample_funcname ( var_0 : str , var_1 : int ) -> int :
      var_2 = len ( var_0 )
      var_3 = 0
      for var_4 in range ( 1 , 27 ) :
          var_5 = dict ( )
          var_6 = 0
          var_7 = 0
          var_8 = 0
          var_9 = 0
          while var_7 < var_2 :
              if var_8 <= var_4 :
                  var_10 = var_0 [ var_7 ]
                  var_5 [ var_10 ] = var_5.get ( var_10 , 0 ) + 1
                  if var_5 [ var_10 ] == 1 :
                      var_8 += 1
                  if var_5 [ var_10 ] == var_1 :
                      var_9 += 1
                  var_7 += 1
              else :
                  var_11 = var_0 [ var_6 ]
                  var_5 [ var_11 ] = var_5.get ( var_11 , 0 ) - 1
                  if var_5 [ var_11 ] == 0 :
                      var_8 -= 1
                  if var_5 [ var_11 ] == var_1 - 1 :
                      var_9 -= 1
                  var_6 += 1
              if var_8 == var_4 and var_9 == var_4 :
                  var_3 = max ( var_3 , var_7 - var_6 )
      return var_3
  