#3346
Maximum Frequency of an Element After Performing Operations I
expert · 1020 · lc medium +32 · 40.1% accepted · 614 likes · top 19%
Description
You are given an integer array nums and two integers k and numOperations.
Perform exactly numOperations operations on nums, where each operation:
- Chooses a previously unchosen index i.
- Adds any integer from the range [-k, k] to nums[i].
Return the highest achievable frequency of any single element after all operations.
Code
1
2
3