Most Occurring Number After K Increments

Правка en1, от Dracula1203, 2020-09-10 10:20:27

This is my first blog post.

It would be great if someone could explain their approach.

You are given a list of integers nums and an integer k. Consider an operation where you increment any one element once. Given that you can perform this at most k times, return the resulting value of the most frequently occurring number. If there's more than one solution, pick the smallest possible number.

Constraints : n ≤ 100,000 where n is the length of nums.

TestCase : nums = [1, 1, 1, 2, 2, 2, 4, 4, 4, 4] k = 3

Output : 2

Explanation :

After we increment the 1s, we get [2, 2, 2, 2, 2, 2, 4, 4, 4, 4]

**Link : https://binarysearch.io/problems/Most-Occurring-Number-After-K-Increments**

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Dracula1203 2020-09-10 10:20:27 773 Initial revision (published)