Uber | SDE II | Phone Screen | Reject
Anonymous User
2055

Just wanted to put my experience with the phone screen out there, for people interviewing with Uber in the future. I had done a decent amount of LC for this (don't know the exact number), and focused on tree/graph questions because the team was Maps-based. However, the question that came in the PS really stumped me. If someone could tell me if it is on Leetcode or post a solution, I'd really appreciate it :) Here it is:

Given an int[] array and an integer k, you can increment each element in the array by 1, up to k times, and increment the same number multiple times if necessary. The main goal is to end up with the most possible numbers with the same value. Your output should be the highest frequency, i.e. the frequency of the number that is repeated the most. For example:

  • Array: [10, 2, 1, 2, 1, 1]
  • k: 3
  • Answer: You can end up incrementing the 1s by 1 each, to get [10, 2, 2, 2, 2, 2], where the output is 5, as 2 is repeated 5 times.

Another example:

  • Array: [1, 2, 4, 3]
  • k: 1
  • Answer: You can add 1 to any value and get an output of 2, e.g. [2,2,4,3]

I tried sorting, then running a two pointer approach. But I think the optimal solution would be using DP of some sort.

Comments (2)