Easy to understand || simple || O(N)
\nclass Solution {\npublic:\n    vector<int> minOperations(string s) \n    {\n        int n=s.size();\n        vector<int>r(n),v(n,0);\n        int cnt=0,i;\n  
```\nclass Solution {\npublic:\n    vector<int> minOperations(string s) \n    {\n        int n=s.size();\n        vector<int>r(n),v(n,0);\n        int cnt=0,i;\n        v[0]=s[0]-\'0\';\n        for(i=1;i<n;i++)\n        {\n            v[i]=v[i-1]+(s[i]-\'0\');//pre-computed array to find total balls at ith position.\n            if(s[i]==\'1\')\n                cnt+=i;\n        }\n        r[0]=cnt;\n        for(i=1;i<n;i++)\n        {\n\t\t//subtract balls after ith position and add balls before ith position inclusive of ith position.\n            r[i]=cnt+v[i-1]-(v[n-1]-v[i-1]);\n            cnt=r[i];\n        }\n        return r;\n    }\n};\n```
[]