JAVA || BRUTE FORCE || SIMPLE APPROACH || NO PREFIX SUM
IntuitionMy first thought was to track all the indices where '1' exists and calculate the distance for every box.Approach1.Parse the input string and identify t
# Intuition
 My first thought was to track all the indices where '1' exists and calculate the distance for every box.

# Approach
1.Parse the input string and identify the indices of all boxes containing '1'.
2.For each box (index), calculate the sum of absolute differences between the current index and all indices with '1'.
3.Store the results in an array and return it.

# Complexity
- Time complexity:
  O(n^2),where 'n' is the length of the string. 

- Space complexity:
  o(k),where k is the number of boxes containing '1'.

# Code
```java []
class Solution {
    public int[] minOperations(String boxes) {
        ArrayList<Integer>arr=new ArrayList<>();
        char[]ch=boxes.toCharArray();
        int n=ch.length;
        ArrayList<Integer>ones=new ArrayList<>();
        for(int i=0;i<n;i++){
            if(ch[i]=='1'){
                ones.add(i);
            }
        }
// Calculate the sum of distances for each index
        for(int i=0;i<n;i++){
            int sum=0;
            for(int x:ones){
                 sum+=Math.abs(i-x);
            }
            arr.add(sum);

        }
        int[]ans=new int[n];
        for(int i=0;i<n;i++){
            ans[i]=arr.get(i);
        }
    return ans;
    }
}
// [2,4,5]-> index where one comes
// 0 0 1 0 1 1
// 0 1 2 3 4 5 idx  1+2+1
// [11,8,5,4,3,4]
```
['Java']