C++ solution using prefix and suffix count of zeros
Make  vectora contains index of 1.\n2.  pz prefix array contain pz[i] --> cnt of zeros between first 1 and ith 1.\n3.  similarly sz suffix array contain  sz[i] 
1.  Make  vector<int>a contains index of 1.\n2.  pz prefix array contain pz[i] --> cnt of zeros between first 1 and ith 1.\n3.  similarly sz suffix array contain  sz[i] -> cnt of zeros from last 1 to ith 1.\n4.  pre is prefix sum of pz.\n5.  suf is suffix sum of sz.\n6.  relation to count total swap in k length window  val = (suf[i-x]-suf[i]-x*sz[i]) + (pre[i+x]-pre[i]-x*pz[i]);\n\n\n```\nclass Solution {\npublic:\n    int minMoves(vector<int>& A, int k) {\n        \n        int i,j;\n        \n        int n=A.size();\n        \n        \n        vector<int>a,pz,sz;\n        \n        int cnt=0;\n        int ao=0;   \n        \n        \n        for(i=0;i<n;i++)\n        {\n            \n            if(A[i]==0)\n            {\n                if(ao)\n                {\n                    cnt++;\n                }\n            }\n            if(A[i]==1)\n            {\n                ao++;\n                a.push_back(i);\n                pz.push_back(cnt);\n            }\n        }\n        \n        \n        cnt=0;\n        ao=0;\n        \n        for(i=n-1;i>=0;i--)\n        {\n            if(A[i]==0)\n            {\n                if(ao)\n                {\n                    cnt++;\n                }\n            }\n            if(A[i]==1)\n            {\n                ao++;\n                sz.push_back(cnt);\n            }\n            \n        }\n        \n        vector<int>pre,suf;\n        int sum=0;\n        \n        for(i=0;i<pz.size();i++)\n        {\n            sum+=pz[i];\n            pre.push_back(sum);\n        }\n        \n        sum=0;\n        for(i=0;i<sz.size();i++)\n        {\n            sum+=sz[i];\n            suf.push_back(sum);\n        }\n        \n        reverse(sz.begin(),sz.end());\n        reverse(suf.begin(),suf.end());\n    \n        int ans=INT_MAX;\n        int x=k/2;\n        \n        if(k%2)\n        {\n            for(i=0;i<a.size();i++)\n            {\n             \n                int val=INT_MAX;\n                if(i-x>=0 && i+x<a.size())\n                    val = (suf[i-x]-suf[i]-x*sz[i]) + (pre[i+x]-pre[i]-x*pz[i]);\n                ans=min(ans,val);\n            }\n        }\n        else\n        {\n            int y=x-1;\n            for(i=0;i<a.size();i++)\n            {\n                int val=INT_MAX;\n                int vall=INT_MAX;\n            \n                if(i-x>=0 && i+y<a.size())\n                  val = (suf[i-x]-suf[i]-x*sz[i]) + (pre[i+y]-pre[i]-y*pz[i]);\n                if(i-y>=0 && i+x<a.size())\n                  vall = (suf[i-y]-suf[i]-y*sz[i]) + (pre[i+x]-pre[i]-x*pz[i]);\n                ans=min(ans,val);\n                ans=min(ans,vall);\n            }\n            \n        }\n        return ans;\n    }\n};\n\n\n\n```
[]