✅✅✅ 98%18 of time and memory solution
\n\n\nclass Solution:\n    def minOperations(self, boxes: str) -> List[int]:\n        l, ans = len(boxes), []\n        left, right = 0, sum(i for i in range(l) 
![Screenshot 2023-01-02 at 20.37.33.png](https://assets.leetcode.com/users/images/2f305629-3c2d-4c8c-9607-9faa25cc937d_1672673898.8989983.png)\n\n```\nclass Solution:\n    def minOperations(self, boxes: str) -> List[int]:\n        l, ans = len(boxes), []\n        left, right = 0, sum(i for i in range(l) if boxes[i]==\'1\')\n        one_left, one_right = 0, boxes.count(\'1\')\n        for i in range(l):\n            ans.append(left+right)\n            if boxes[i]==\'1\':\n                one_left, one_right = one_left+1, one_right-1\n            left, right = left+one_left, right-one_right\n        return ans\n\n```
['Python', 'Python3']