C++ O(N) Solution || Very Simple || 100 % faster in runtime  and space
Intution is simple - \nWe need to perform two pass of the boxes in linear time one from left to right and vice versa.\nTwo variable step and ball are getting up
Intution is simple - \nWe need to perform two pass of the boxes in linear time one from left to right and vice versa.\nTwo variable **step** and **ball** are getting updated in both the passes. At every index, we need to look into sum of previous step and number of ball till previous index in first pass from right to left.\nAnd in second pass left to right, we do exactly the same thing.\n```\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) {\n        int n=boxes.size();\n        vector<int> ans(n);\n        int step=0, ball=0;\n        for(int i=n-1; i>=0; i--){\n            ans[i] = step;\n            if(boxes[i] == \'1\') ball++;\n            step += ball;\n        }\n        step=0; ball=0;\n        for(int i=0; i<n; i++){\n            ans[i]+=step;\n            if(boxes[i] == \'1\') ball++;\n            step+=ball;\n        }\n        return ans;\n    }\n};\n```
['C']