Interview Query

Finding The Mode

Start Timer

0:00:00

Upvote
5
Downvote
Save question
Mark as completed
View comments (10)
Next question

Write a function to determine the mode of an array of integers.

The list may have one mode, more than one mode, or no mode at all. If the list has multiple modes, return them in ascending order.

Example 1:

Input:

nums = [1, 2, 2, 3, 4]

Output:

mode(nums) -> [2]

Example 2:

Input:

nums = [1,1,2,2]

Output:

mode(nums) -> [1, 2]
.
.
.
.
.


Comments

Loading comments.