FastPrepMost Frequent Name
Problems/Most Frequent Name

Most Frequent Name

Amazon logoAmazon● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task identifies this algorithmic exercise. The executable interface, bounds, deterministic tie rules, and examples are the documented practice contract.

Given a nonempty array of case-sensitive names, return the name that appears most often.

If multiple names have the same maximum frequency, return the lexicographically smallest tied name.

Function

mostFrequentName(names: String[]) → String

Examples

Example 1

names = ["ana","bob","ana"]return = "ana"

Case 1 exercises the documented deterministic contract.

Example 2

names = ["zoe","amy","zoe","amy"]return = "amy"

Case 2 exercises the documented deterministic contract.

Example 3

names = ["solo"]return = "solo"

Case 3 exercises the documented deterministic contract.

Constraints

  • 1 <= names.length <= 200000.
  • 1 <= names[i].length <= 100.
  • Names contain printable ASCII characters and comparisons are case-sensitive.

More Amazon problems

  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public String mostFrequentName(String[] names) {
        // Write your code here.
    }

}
Checking account…