simple and easy O(n) C++ solution 😍❤️‍🔥
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook
\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\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    {\n        int n = boxes.size(), oneCount = 0, op = 0;\n        vector<int>ans(n);\n\n        for(int i=0;i<n;i++)\n        {\n            ans[i] = op;\n            oneCount += boxes[i] == \'1\';\n            op += oneCount;\n        }\n        oneCount = op = 0;\n        for(int i=n-1;i>=0;i--)\n        {\n            ans[i] += op;\n            oneCount += boxes[i] == \'1\';\n            op += oneCount;\n        }\n        return ans;\n    }\n};\n```
['Array', 'String', 'C++']