Back to course home
0% completed
Vote For New Content
Frequency of the Most Frequent Element (medium)
Problem Statement
You are given an nums array containing n integers and an integer k. In a single operation, you can choose any index i and increment the nums[i] by 1.
Return the maximum possible frequency of any element of nums after performing at most k operations.
Examples
Example 1:
- Input:
nums = [1, 2, 3],k = 3 - Expected Output: 3
- Explanation: We can increment the number 1 two times and 2 one time. The final array will be [3, 3, 3]. Now, the number 3 appears 3 times in the array [3, 3, 3].
Example 2:
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!