C++ SOLUTION USING BINARY SEARCH
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:  O(N LOG(N))\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```\n#define ll long long \nclass Solution {\npublic:\n    \n\nbool fun(vector<int> &v , vector<ll> & left ,vector<ll>&right , int mid , ll target ){\nll n= v.size();\n\n\n//  NOW WE HAVE TWO CASES \n// 1. FOR EVEN NUMBER (we have two cases but these case generate same output) \n// a. left side has one less element than n/2 \n// b. right side has one less element than n/2\n// 2. FOR ODD NUMBER (we have equal number of element in left and right side )\n\n\n// FOR ODD NUMBER \n\nif(mid%2){\nll k = mid/2;\nfor(int i=k; i<(n-k); i++){\n\n//  calculate previous element sum \nll leftindex = i-k-1;\nll leftsum = left[i];\nif(leftindex>=0){\n    leftsum-=left[leftindex];\n}\n\n\n//  calculate  nextelement sum \nll rightindex = i+k+1;\nll rightsum = right[i];\nif(rightindex<n){\n    rightsum-=right[rightindex];\n}\n\n\n//  now calculate final ans\nll totalsum = v[i]*(k+1);\nll ans = abs(totalsum-leftsum) + abs(totalsum-rightsum);\nif(ans<=target) return true; \n\n\n}\n\n}else{\n\nll k = mid/2;\n    for(int i=k-1; i<(n-k); i++){\n//  calculate left sum\n        ll lefttotal = v[i]*k;\n ll leftindex =i-k;\n ll leftsum = left[i];\n if(leftindex>=0){\n    leftsum-=left[leftindex];\n }\n\n\n//  calculate right sum \n ll righttotal = v[i]*(k+1);\n ll rightindex = i+k+1;\n ll rightsum = right[i];\n if(rightindex<n){\n    rightsum-=right[rightindex];\n }\n\n //  final answer\n ll ans = abs(lefttotal-leftsum) +abs(righttotal-rightsum);\nif(ans<=target) return true; \n    }\n\n\n\n\n\n\n\n\n}\n\n\n\nreturn false;\n}\n\n\n\n    int maxFrequencyScore(vector<int>& v, long long k) {\n        int n = v.size();\n            //  sort the array\n            sort(v.begin(),v.end());\n\n\n            // prefix and suffix sum array\n\n\n            vector<ll> left(n);\n            for(int i=0; i<n; i++){\n                if(i==0) left[i]=v[i];\n                else left[i]=left[i-1]+v[i];\n            }\n\n            vector<ll> right(n);\n            for(int i=n-1; i>=0; i--){\n                if(i==(n-1)) right[i]=v[i];\n                else right[i]=right[i+1]+v[i];\n            }\n\n       //  using binary search \n            int  low =0;\n            int high = INT_MAX;\n            while(low<=high){\n                int mid = low + (high-low)/2;\n                if(fun(v,left,right,mid,k)){\n                 low =mid+1;\n                }else{\n                    high=mid-1;\n\n                }\n            }\n            \ncout<<" ANS "<<high<<endl;\n        return high;\n    }\n};\n```
['Binary Search', 'Prefix Sum', 'C++']