2968. Apply Operations to Maximize Frequency Score
You are given a 0-indexed integer array
nums
and an integerk
.You can perform the following operation on the array at most
k
times:
- Choose any index
i
from the array and increase or decreasenums[i]
by1
.The score of the final array is the frequency of the most frequent element in the array.
Return the maximum score you can achieve.
The frequency of an element is the number of occurences of that element in the array.
1 | class Solution { |