c++ | easy | short
\n\n# Code\n\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) \n    {\n        vector<int> v;\n        int leftcount=0; \n        int lef
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) \n    {\n        vector<int> v;\n        int leftcount=0; \n        int leftsum=0; \n        int rightsum=0; \n        int rightcount=0; \n        for(int i=0;i<boxes.size();i++)\n        {\n            if(boxes[i]==\'1\')\n            {\n                rightsum+=i;\n                rightcount++;\n            }\n        }\n        \n        for(int i=0;i<boxes.size();i++)\n        {\n            if(boxes[i]==\'1\')\n            {\n                rightcount--;\n                rightsum-=i;\n            }\n            int sum=abs(rightsum-(rightcount*i))+abs(leftsum-(leftcount*i));\n            v.push_back(sum);\n            if(boxes[i]==\'1\')\n            {\n                leftcount++;\n                leftsum+=i;\n            }\n                                                     \n        }\n        return v;\n    }\n};\n```
['C++']