#3347
Maximum Frequency of an Element After Performing Operations II
candidate master · 1330 · lc hard +32 · 53.9% accepted · 300 likes · top 45%
Description
You are given an integer array nums and two integers k and numOperations.
Perform at most numOperations operations on nums. Each operation:
- Selects a previously unselected index i.
- Adds some integer in [-k, k] to nums[i].
Return the highest frequency any single value can reach after the operations.
Code
1
2
3