comefrom: <doocs>2134.Minimum Swaps to Group All 1's Together II_1.py
code: def minSwaps( nums: List[int]) -> int:
      cnt = nums.count(1)
      n = len(nums)
      s = [0] * ((n << 1) + 1)
      for i in range(n << 1):
          s[i + 1] = s[i] + nums[i % n]
      mx = 0
      for i in range(n << 1):
          j = i + cnt - 1
          if j < (n << 1):
              mx = max(mx, s[j + 1] - s[i])
      return cnt - mx
masked: def sample_funcname ( var_0 : List [ int ] ) -> int :
      var_1 = var_0.count ( 1 )
      var_2 = len ( var_0 )
      var_3 = [ 0 ] * ( ( var_2 << 1 ) + 1 )
      for var_4 in range ( var_2 << 1 ) :
          var_3 [ var_4 + 1 ] = var_3 [ var_4 ] + var_0 [ var_4 % var_2 ]
      var_5 = 0
      for var_4 in range ( var_2 << 1 ) :
          var_6 = var_4 + var_1 - 1
          if var_6 < ( var_2 << 1 ) :
              var_5 = max ( var_5 , var_3 [ var_6 + 1 ] - var_3 [ var_4 ] )
      return var_1 - var_5
  