Easy C++ Solution;
\n# Complexity\n- Time complexity: O(n*log(n))\n\n- Space complexity: O(n)\n\n# Code\n\n\nclass Solution {\npublic:\n    //sort the array-->so that it will for 
\n# Complexity\n- Time complexity: O(n*log(n))\n\n- Space complexity: O(n)\n\n# Code\n```\n\nclass Solution {\npublic:\n    //sort the array-->so that it will for a continous sequence\n    //We will apply binarySearch on answer\n    //we will take a window of size mid and with the help of prefix sum find if \n    //it is fessible or not\n    typedef long long int ll;\n    bool isPossible(vector<int>& nums, long long K,int mid,vector<ll> prefix){\n        int n=nums.size();\n        int i=0;\n        int j=mid-1;\n\n          while(j < n) {\n            ll target_idx = (i+j) / 2;\n            ll target     = nums[target_idx];\n            \n            \n            ll operations_left  = 0;\n            ll operations_right = 0;\n            \n            if(target_idx == 0) {\n                operations_left = 0;\n            } else {\n                operations_left = abs(((target_idx - i) * target) - (prefix[target_idx-1] - (i > 0 ? prefix[i-1] : 0)));\n            }\n            \n            operations_right    = abs(((j - target_idx) * target) - (prefix[j] - prefix[target_idx]));\n          \n            if(operations_right + operations_left <= K) {\n                return true;\n            }\n            \n            i++;\n            j++;\n        }\n\n        return false;\n    }\n    int maxFrequencyScore(vector<int>& nums, long long k) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        vector<ll> prefix(n,0);\n        prefix[0]=(ll)nums[0];\n        for(int i=1;i<n;i++){\n            prefix[i]=prefix[i-1]+nums[i];\n        }\n\n        int s=1;\n        int e=n;\n        int mid=s+(e-s)/2;\n        int ans=0;\n        while(s<=e){\n            if(isPossible(nums,k,mid,prefix)){\n              ans=mid;\n              s=mid+1;\n            }\n            else{\n                e=mid-1;\n            }\n            mid=s+(e-s)/2;\n        }\n\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Sliding Window', 'Sorting', 'Prefix Sum', 'C++']