FastPrepCandidate Alias Name Matching

Candidate Alias Name Matching

Checkr logoCheckr● MediumFULLTIMENEW GRADOAPHONE SCREEN
Learn

Problem statement

Given a list of known candidate aliases and a name returned on a record, return whether the record name matches at least one alias.

Names contain a first name, an optional middle name or initial, and a last name. Last names must match exactly. A missing middle name is compatible with any middle name. A one-letter middle initial matches a middle name with the same initial. The first and middle names may be transposed; the last name may not move.

Object-model variation

Another reported interview asks for a Name class whose constructor takes a name string and parses its first, optional middle, and last parts, with __eq__(other) implementing name matching.

For this practice variation, use the matching rules above for two parsed names. The graded interface remains nameMatch(knownAliases, recordName); the class variation is a follow-up.

Function

nameMatch(knownAliases: String[], recordName: String) → boolean

Examples

Example 1

knownAliases = ["Alphonse Gabriel Capone","Al Capone"]recordName = "Alphonse Gabriel Capone"return = true

The record exactly matches the first alias.

Example 2

knownAliases = ["Alphonse Gabriel Capone"]recordName = "Gabriel A Capone"return = true

The first and middle names are transposed and the initial matches Alphonse.

Constraints

  • 1 <= knownAliases.length <= 1000.
  • Every name has two or three non-empty space-separated parts.
  • Matching is case-sensitive.
  • For this exercise, assume every part contains ASCII letters and parts are separated by exactly one ASCII space, with no leading or trailing spaces.
See Checkr hiring insights
public boolean nameMatch(String[] knownAliases, String recordName) {
    // Write your code here.
}
knownAliases["Alphonse Gabriel Capone","Al Capone"]
recordName"Alphonse Gabriel Capone"
expectedtrue
Checking account…