Easy Explanation | Python | Time: O(n) and Space: O(1) 
IntuitionThe goal is to compute the minimum number of operations needed to move all balls to each box. The operations depend on the distances of all the balls f
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The goal is to compute the minimum number of operations needed to move all balls to each box. The operations depend on the distances of all the balls from the target box. To avoid recalculating distances for each box, the solution splits the work into two linear passes, one from left to right and another from right to left, to track cumulative operations efficiently.

# Approach
<!-- Describe your approach to solving the problem. -->
- **Perform a left-to-right pass:**

    Use bl (balls on the left) and ml (operations from the left) to calculate the operations for each box and update the result array.
    Update bl and ml as you move to the next box.
- **Perform a right-to-left pass:**

    Use br (balls on the right) and mr (operations from the right) to add the operations for each box.
    Update br and mr similarly.
- The sum of the results from both passes gives the final operations for each box.

# Complexity Analysis
- Time complexity: O(n) for two linear passes over the string of length n.
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1) excluding result array.
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minOperations(self, boxes: str) -> List[int]:
        bl, br = 0, 0
        ml, mr = 0, 0
        n = len(boxes)
        res = [0]*n
        for i in range(n):
            res[i] += bl + ml
            j = n-1-i
            res[j] += br + mr
            ml = bl + ml
            mr = br + mr
            bl += 1 if boxes[i] == '1' else 0
            br += 1 if boxes[j] == '1' else 0
            # print(res, i)
        return res


```
['Prefix Sum', 'Python3']