Back to questions

Most Popular Integers Google Python Interview Question

Most Popular Integers

Google Python Interview Question

Given an integer array and an integer as input, return the top integers in the array (the ones that appear most frequently). Return the output in non-decreasing order. The test cases are generated in such a way that there will be a unique answer.

Example #1

Input:

Output:

Explanation: The most frequent elements are: with a frequency of , with a frequency of , and with a frequency of . Finally, the output is sorted in non-decreasing order.

Example #2

Input:

Output:

Input

Python

Output