Candidate Alias Name Matching
Updated
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
A variant 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 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) → booleanExamples
Example 1
knownAliases = ["Alphonse Gabriel Capone","Al Capone"]recordName = "Alphonse Gabriel Capone"return = trueThe record exactly matches the first alias.
Example 2
knownAliases = ["Alphonse Gabriel Capone"]recordName = "Gabriel A Capone"return = trueThe 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.
Similar questions at other companies
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Count Suffix Word PairsTikTok · OATikTok interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Count One-Swap Number PairsCapital One · OACapital One interview questions
- Group AnagramsEPAM · PHONE SCREENEPAM interview questions
- Underline Shortest Unique SubstringsMoveworks · PHONE SCREENMoveworks interview questions
- Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
- Invalid TransactionsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions