100% Faster C++ Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) {\n        int n=boxes.length();\n        vector<int>op(n);\n        int suml=0,sumr=0;\n        for(int i=0;i<n;i++){\n            if(boxes[i]==\'1\'){\n                sumr+=1;\n                op[0]+=i;    \n            }\n        }\n        for(int i=1;i<n;i++){\n            if(boxes[i-1]!=\'0\'){\n                suml+=1;\n                sumr-=1;\n            }\n            op[i]=op[i-1]+suml-sumr; \n        }\n        return op;\n    }\n};\n```
['C++']