Dracula1203's blog

By Dracula1203, history, 4 years ago, In English

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**

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it