FastPrepFastPrep
Problem Brief

Find Maximum Frequency of Number

NEW GRADONSITE INTERVIEW
See Google online assessment and hiring insights

Given a sorted array, find the maximum frequency of a number.

Example: [1,2,2,3,3,3,3,4,4,5,6] : Answer: 4 (3 is repeated 4 times).

O(N) is a straightforward solution. Asked if the performance can be improved.

1Example 1

Input
nums = [1,2,2,3,3,3,3,4,4,5,6]
Output
4
Explanation
In the given array, the number 3 appears the maximum number of times, which is 4 times.

Constraints

Limits and guarantees your solution can rely on.

πŸ‡πŸ‡
public int findMaximumFrequency(int[] nums) {
  // write your code here
}
Input

nums

[1,2,2,3,3,3,3,4,4,5,6]

Output

4

Sign in to submit your solution.