[Python3] One Pass O(1) Space Beats 100%
\nclass Solution:\n    def minOperations(self, boxes: str) -> List[int]:\n        n = len(boxes)\n        res, f, b, cf, cb = [0] * n, 0, 0, 0, 0\n        for i
```\nclass Solution:\n    def minOperations(self, boxes: str) -> List[int]:\n        n = len(boxes)\n        res, f, b, cf, cb = [0] * n, 0, 0, 0, 0\n        for i in range(n):\n            res[i] += cf * i - f\n            cf += boxes[i] == \'1\'\n            f += i if boxes[i] == \'1\' else 0\n            res[n - i - 1] += cb * i - b\n            cb += boxes[n - i - 1] == \'1\'\n            b += i if boxes[n - i - 1] == \'1\' else 0\n        return res\n```
[]