comefrom: <doocs>1769.Minimum Number of Operations to Move All Balls to Each Box_1.py
code: def minOperations( boxes: str) -> List[int]:
      n = len(boxes)
      res = [0] * n
      total = 0
      for i, b in enumerate(boxes):
          if b == '1':
              res[0] += i
              total += 1
      left, right = 0, total
      for i in range(1, n):
          if boxes[i - 1] == '1':
              left += 1
              right -= 1
          res[i] = res[i - 1] + left - right
      return res
masked: def sample_funcname ( var_0 : str ) -> List [ int ] :
      var_5 = len ( var_0 )
      var_7 = [ 0 ] * var_5
      var_8 = 0
      for var_10 , var_11 in enumerate ( var_0 ) :
          if var_11 == '1' :
              var_7 [ 0 ] += var_10
              var_8 += 1
      var_14 , var_15 = 0 , var_8
      for var_10 in range ( 1 , var_5 ) :
          if var_0 [ var_10 - 1 ] == '1' :
              var_14 += 1
              var_15 -= 1
          var_7 [ var_10 ] = var_7 [ var_10 - 1 ] + var_14 - var_15
      return var_7
  