3346. Maximum Frequency of an Element After Performing Operations I
You are given an integer array
nums
and two integersk
andnumOperations
.You must perform an operation
numOperations
times onnums
, where in each operation you:
- Select an index
i
that was not selected in any previous operations.- Add an integer in the range
[-k, k]
tonums[i]
.Return the maximum possible frequency of any element in
nums
after performing the operations.The frequency of an element
x
is the number of times it occurs in the array.
1 | class Solution { |