Simple solution | Sliding window | O(NlogN) | Beats 100%
Intuition\nMoves calculation is same as previous contest problem\'s cost calculation.\nThe question:\n2967. Minimum Cost to Make Array Equalindromic\n Describe 
# Intuition\nMoves calculation is same as previous contest problem\'s cost calculation.\nThe question:\n2967. Minimum Cost to Make Array Equalindromic\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Complexity\n- Time complexity: O(NlogN)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maxFrequencyScore(int[] nums, long k) {\n        Arrays.sort(nums);\n        int n = nums.length;\n        long[] pre = new long[n+1];\n        for(int i=1 ; i<=n ; i++)\n            pre[i] = pre[i-1] + nums[i-1];\n        \n        int mxFreq = 1;\n        int i = 0, j = 0;\n        while(i<=j && j!=n){\n            if(minMovesNeeded(pre, i, j)<=k){\n                mxFreq = Math.max(mxFreq, j-i+1);\n                j++;\n            }\n            else \n                i++;\n        }\n        return mxFreq;\n    }\n    public long minMovesNeeded(long[] pre, int lo, int hi){\n        if((hi-lo+1)%2==0){\n            long val = pre[hi+1]+pre[lo] - 2*pre[(hi+lo)/2+1];\n            return val;\n        }\n        else {\n            int mid = (lo+hi)/2;\n            long val = pre[hi+1] + pre[lo] - pre[mid+1] - pre[mid];\n            return val;\n        }\n    }\n}\n```
['Sliding Window', 'Prefix Sum', 'Java']