java median sequence + sliding window
```\nclass Solution {\n    public int minMoves(int[] nums, int k) {\n        int len = nums.length;\n        int cnt = 0;\n        long min = Long.MAX_VALUE;\n 
```\nclass Solution {\n    public int minMoves(int[] nums, int k) {\n        int len = nums.length;\n        int cnt = 0;\n        long min = Long.MAX_VALUE;\n        for(int num : nums)\n            if(num == 1)\n                cnt++;\n        int[] arr = new int[cnt];\n        int idx = 0;\n        long[] sum = new long[cnt+1];\n        for(int i=0; i<len; i++)\n            if(nums[i] == 1){\n                arr[idx++] = i;\n                sum[idx] = sum[idx-1]+i;\n            }\n        for(int i=0; i+k-1<cnt; i++)\n            min = Math.min(min, getSum(arr, i, i+k-1, sum));\n        return (int)min;\n    }\n    public long getSum(int[] arr, int l, int h, long[] sum){\n        int mid = l+(h-l)/2;\n        int k = h-l+1;\n        int radius = mid-l;\n        long res = sum[h+1]-sum[mid+1]-(sum[mid]-sum[l]) - (1+radius)*radius;\n        if(k%2==0)\n            res = res - arr[mid] - (radius+1);\n        return res;\n    }\n}
[]