Highest Frequency

In this problem, we'll learn how to keep a count of values as we go through an array. From that data, we'll return the most common string in the array.

Highest Frequency

Instructions

Write a function that takes an array of strings and returns the most commonly occurring string in that array.

If there are multiple strings with the same high frequency, return the one that finishes its occurrences first, while going left to right through the array.

Input: Array of Strings

Output: String


Level up your interview prep. Join Educative to access 70+ hands-on prep courses.