Ctrl K
Problem

Most Common Values

Medium · Most Common Values

You are given an integer array `values` and a number `count`. Find the `count` distinct values that occur in the array most often and return them in any order. The answer is guaranteed to be unique: the value ranked `count`-th by frequency occurs strictly more often than any value left out of the answer. Aim for better than O(n log n) time.…

Solve the problem →