C++ || O(N) Time
\n    vector minOperations(string boxes) \n    {\n        int n = boxes.size();\n        vector res;\n        int sum = 0, right = 0, left = 0;\n        \n     
\n    vector<int> minOperations(string boxes) \n    {\n        int n = boxes.size();\n        vector<int> res;\n        int sum = 0, right = 0, left = 0;\n        \n        for(int i = 0; i < n; i++)\n        {\n            if(boxes[i] == \'1\')\n            {\n                sum += i;\n                right++;\n            }\n        }\n        \n        for(int i = 0; i < n; i++)\n        {\n            res.push_back(sum);\n            if(boxes[i] == \'1\')\n            {\n                right--;\n                left++;\n            }\n            \n            sum += left - right;\n        }\n        \n        return res;\n                \n        \n    }\n
['C', 'C++']