VERY EASY C++ O(N) TWO PASS ANSWER
\n\n# Complexity\n- Time complexity:\nO(N)\n- Space complexity:\nO(N)\n# Code\n\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) {\n     
\n\n# Complexity\n- Time complexity:\nO(N)\n- Space complexity:\nO(N)\n# Code\n```\nclass Solution {\npublic:\n    vector<int> minOperations(string boxes) {\n        vector<int>ans(boxes.size());\n\n        int travel=0,ones=0;\n        for(int i=0;i<boxes.size();i++)\n        {\n                travel=travel+ones;\n                ans[i]=travel;\n                if(boxes[i]==\'1\')\n                    ones++;\n        }\n        travel=0,ones=0;\n        for(int i=boxes.size()-1;i>=0;i--)\n        {\n                travel=travel+ones;\n                ans[i]=ans[i]+travel;\n                if(boxes[i]==\'1\')\n                    ones++;\n        }\n        return ans;\n\n    }\n};\n```\n\n\n![8f76da41-5b5f-43d9-91dd-3f6122e4e478_1687847851.2763731.jpeg](https://assets.leetcode.com/users/images/1be6de7f-f2af-4d2d-b9e1-9bef3af79bd6_1696247035.7447019.jpeg)\n
['C++']