ez sol
\n Add your space complexity here, e.g. O(n) \n\n# Code\n\nclass Solution:\n    def minMoves(self, nums: List[int], k: int) -> int:\n        if k==1:\n         
\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minMoves(self, nums: List[int], k: int) -> int:\n        if k==1:\n            return 0\n        n=len(nums)\n        ind=[i for i in range(len(nums)) if nums[i]==1]\n        pref=[0]*n\n        for i in range(n):\n            pref[i]+=pref[i-1]+(nums[i]==0)\n        win=ind[:k]\n        l,hi=0,k-1\n        sl,sr=0,0\n        ans=float("inf")\n        lh=k//2\n        rh=k-k//2\n        sl=sum([pref[i] for i in win[:k//2]])\n        sr=sum([pref[i] for i in win[k//2:]])\n        li=deque(win[:k//2])\n        ri=deque(win[k//2:])\n        win=deque(win)\n        while hi<len(ind):\n            ans=min(ans,(pref[win[k//2]]*lh)-sl+(sr-(pref[win[k//2]]*rh)))\n            l+=1\n            hi+=1\n            if hi<len(ind):\n                x=win.popleft()\n                xl=li.popleft()\n                xr=ri.popleft()\n                sl-=pref[xl]\n                sl+=pref[xr]\n                li.append(xr)\n                ri.append(ind[hi])\n                sr-=pref[xr]\n                sr+=pref[ind[hi]]\n                win.append(ind[hi])\n\n        return ans\n```
['Python3']