Java Code for greedy approach
Intuition\n Describe your first thoughts on how to solve this problem. \nEffecient solution using prefix sum array and iterating through while loop to find the 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEffecient solution using prefix sum array and iterating through while loop to find the left sum and right sum.The intuition behind the code is to consider different windows of size k within the ones list and calculate the minimum number of moves required to make each subarray symmetric. The code keeps track of the minimum moves encountered and returns the overall minimum.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPrefix-sum+Sliding Window with greedy approach\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport java.util.ArrayList;\nimport java.util.List;\n\nclass Solution {\n    public int minMoves(int[] nums, int k) {\n      \n        List<Integer> ones = new ArrayList<>();\n        for (int i = 0; i < nums.length; i++) {\n            if (nums[i] == 1) {\n                ones.add(i);\n            }\n        }\n        int prefSum[]=new int[ones.size()];\n        prefSum[0] =ones.get(0);\n        for(int i = 1; i < ones.size(); i++)\n            prefSum[i] = prefSum[i - 1] + ones.get(i);\n\n        \n        int minMoves = Integer.MAX_VALUE;\n        int left = 0;\n        int right = k - 1;\n        while(right<ones.size()){\n            if(k%2==0){\n                int mid = (left + right) / 2;\n                int radius=mid-left;\n                int excessMoves;int total=0;\n               int lsum=(mid == 0 ? 0 : prefSum[mid-1]) - (left == 0 ? 0 : prefSum[left-1]);\n              int rsum=prefSum[right]-prefSum[mid] ;\n               excessMoves=radius*(radius+1)+(radius+1);\n               total=rsum-lsum-ones.get(mid)-(excessMoves);\n               minMoves=Math.min(minMoves,total);\n            }\n            else{\n                int mid = (left + right) / 2;\n                int radius=mid-left;\n                int excessMoves;int total=0;\n               int lsum=(mid == 0 ? 0 : prefSum[mid - 1]) - (left == 0 ? 0 : prefSum[left - 1]);\n              int rsum=prefSum[right]-prefSum[mid] ;\n               excessMoves=radius*(radius+1);\n               total=rsum-lsum-(excessMoves);\n                minMoves=Math.min(minMoves,total);\n            }\n            left+=1;\n            right+=1;\n        }\n       \n   return minMoves;\n    }\n}\n\n\n```
['Greedy', 'Sliding Window', 'Prefix Sum', 'Java']