FastPrepSearch and Format Contacts
Problems/Search and Format Contacts

Search and Format Contacts

Adyen logoAdyen● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Adyen asked this in a Kotlin live-coding video round for a backend Kotlin role, after a recruiter call. There were no algorithm puzzles. The task was to read a JSON list of contacts, some without an email, into objects, search them by name, print each match in a set format, and write unit tests. In the candidate's own solution, the search matched the start of the name, ignored case and trimmed spaces, and the last name and email were printed only when present.

The report shared the contact list it used, but no function signature. We chose these: the contacts come as parallel arrays instead of JSON text, so every language can solve it without a JSON library. The match is on the first name only. Matches keep input order. Unit tests are not checked here. Sizes have the limits listed below.

Our version is about 75% the same as the reported question.

You are building the search screen of a contacts app. Contact i has a first name names[i], an optional last name lastNames[i] (an empty string means none), a phone number numbers[i] and an optional email emails[i] (an empty string means none).

Given a search string query, remove spaces from both ends of it. A contact matches when its first name starts with the trimmed query, ignoring upper and lower case. An empty trimmed query matches every contact.

Return one line for each matching contact, in input order, formatted as the first name, then a space and the last name if there is one, then ": " and the number, then ", " and the email if there is one. For example, Bob Smith: 4441234567 and Alice: 1234567890, alice@example.com.

Function

searchContacts(names: String[], lastNames: String[], numbers: long[], emails: String[], query: String) → List<String>

Examples

Example 1

names = ["John","Alice","Ali","Bob","Sarah","Bobby","Michael","Emily","David","Jonathan","Bobbi"]lastNames = ["","","","","","","","","","",""]numbers = [50291238,1231238761,559123876,349912387,2119123876,299912387,1291238761,294912387,299712387,493912387,299912387]emails = ["John@adyen.com","alice@adyen.com","ali@adyen.com","","Sarah@adyen.com","","michael@adyen.com","emily@adyen.com","","","Bobbi@adyen.com"]query = "Ali"return = ["Alice: 1231238761, alice@adyen.com","Ali: 559123876, ali@adyen.com"]
  • Both Alice and Ali start with Ali. Each line shows the name, a colon, the number and, because both have an email, a comma and the email.

Example 2

names = ["John","Alice","Ali","Bob","Sarah","Bobby","Michael","Emily","David","Jonathan","Bobbi"]lastNames = ["","","","","","","","","","",""]numbers = [50291238,1231238761,559123876,349912387,2119123876,299912387,1291238761,294912387,299712387,493912387,299912387]emails = ["John@adyen.com","alice@adyen.com","ali@adyen.com","","Sarah@adyen.com","","michael@adyen.com","emily@adyen.com","","","Bobbi@adyen.com"]query = "  bob "return = ["Bob: 349912387","Bobby: 299912387","Bobbi: 299912387, Bobbi@adyen.com"]
  • The query is trimmed to bob and compared without case, so Bob, Bobby and Bobbi match, in input order.
  • Bob and Bobby have no email, so their lines end after the number.

Example 3

names = ["Bob","Alice"]lastNames = ["Smith",""]numbers = [4441234567,1234567890]emails = ["","alice@example.com"]query = ""return = ["Bob Smith: 4441234567","Alice: 1234567890, alice@example.com"]
  • An empty query matches every contact.
  • Bob has a last name, which follows his first name: Bob Smith: 4441234567.

Constraints

  • 1 <= n == names.length == lastNames.length == numbers.length == emails.length <= 1000
  • Each names[i] has 1 to 20 English letters; each lastNames[i] has 0 to 20 English letters.
  • 0 <= numbers[i] <= 1010
  • Each emails[i] is empty or has the form local@domain, each part 1 to 30 characters from letters, digits, ., _ and - (no _ in the domain).
  • query has 0 to 20 characters, each an English letter or a space.

More Adyen interview questions

  • Planets Queries from Planet OnePHONE SCREEN · Seen May 2026
  • Count Perfect PairsOA · Seen Aug 2026
  • Find the Tree DiameterONSITE INTERVIEW · Seen Aug 2026
  • Maximize Strength with Disjoint Adjacent SwapsOA · Seen Aug 2026
  • Best TV Show in a GenreOA · Seen May 2026

Similar questions at other companies

  • Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
  • Process Refunds with Bounded RetriesMercor · PHONE SCREENMercor interview questions
  • E-commerce Notification RouterAmazon · PHONE SCREEN
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Validate a Single-Letter Word SequenceReddit · PHONE SCREENReddit interview questions
  • Incremental String Qualification with Split and MergeStripe · PHONE SCREENStripe interview questions
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
  • Elevator Scheduling SimulationOpenAI · PHONE SCREENOpenAI interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Load/Store Arithmetic InterpreterJane Street · PHONE SCREENJane Street interview questions

Interview reports that mention this question

  • Adyen Kotlin Backend Engineer Live Coding: 1 Experience
All Adyen interview questionsSee Adyen hiring insights
Saved
class Solution {
    public List<String> searchContacts(String[] names, String[] lastNames, long[] numbers, String[] emails, String query) {
        // Write your code here.
    }
}
Checking account…