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_2 : int ) -> int :
      var_5 = len ( var_0 )
      var_7 = 0
      for var_11 in range ( 1 , 27 ) :
          var_13 = dict ( )
          var_14 = 0
          var_15 = 0
          var_16 = 0
          var_17 = 0
          while var_15 < var_5 :
              if var_16 <= var_11 :
                  var_18 = var_0 [ var_15 ]
                  var_13 [ var_18 ] = var_13.get ( var_18 , 0 ) + 1
                  if var_13 [ var_18 ] == 1 :
                      var_16 += 1
                  if var_13 [ var_18 ] == var_2 :
                      var_17 += 1
                  var_15 += 1
              else :
                  var_20 = var_0 [ var_14 ]
                  var_13 [ var_20 ] = var_13.get ( var_20 , 0 ) - 1
                  if var_13 [ var_20 ] == 0 :
                      var_16 -= 1
                  if var_13 [ var_20 ] == var_2 - 1 :
                      var_17 -= 1
                  var_14 += 1
              if var_16 == var_11 and var_17 == var_11 :
                  var_7 = max ( var_7 , var_15 - var_14 )
      return var_7
  