← Questions

Deduplicate account sign-ups by email and phone

0
AirbnbCodingLast asked Apr 2026

A coding interview question asked in Airbnb's coding round, last asked Apr 2026. It tests hash set, strings and simulation.

A sign-up service processes account registrations one at a time, in the order they arrive. You get three lists of the same length n: names, emails and phones. Index i of each list describes account i.

Implement:

register_accounts(names: list[str], emails: list[str], phones: list[str]) -> list[bool]

Return a list where entry i is True if account i registers successfully and False if it is a duplicate.

Rules

  • An account registers only if its email is not claimed by an earlier registered account and its phone is not claimed by an earlier registered account.
  • A duplicate account claims nothing. Its email and phone do not block later accounts.
  • names is part of the record but is never used to detect duplicates.
  • Emails and phones are checked separately: an email only collides with emails, a phone only with phones.
  • An empty string (or None) means the field was not given. It never collides.
  • Raise ValueError if the three lists have different lengths.

Part 2: normalization

Real users type the same identifier in different ways. Before checking, normalize:

  • emails: trim surrounding spaces and compare case-insensitively;
  • phones: keep only the digits (so "+1 (415) 555-0100" equals "14155550100").

Example

i name email phone result
0 Ana ana@x.io 111 True
1 Ben ben@x.io 222 True
2 Cy ana@x.io 333 False (email taken by Ana)
3 Dee dee@x.io 222 False (phone taken by Ben)
4 Eli cy@x.io 333 True (Cy never registered, so 333 is free)

Output: [True, True, False, False, True].

Constraints

  • 0 <= n <= 10^5; each email and phone is at most 100 characters.
  • Aim for O(n) time for typical string lengths. State the time and space complexity.

Clarifying questions

  • Is an account with both fields empty always registered, since nothing collides?
  • In Part 2, should an email that is only spaces count as empty after trimming? And a phone with no digits?
  • Should a duplicate's name be used anywhere, such as in a report?
  • Is None allowed in the lists, and should it be treated the same as an empty string?

What a strong answer covers

  • Keeps two sets, emails and phones claimed by registered accounts. For each account it checks both and, only if both are free, registers it and adds its non-empty values to the sets.
  • Does not add a duplicate's email or phone, which is what makes account 4 in the example register.
  • Part 2 runs the normalization before both the check and the insert, so the sets hold only normalized values.
  • O(n * L) time for strings of length L, and O(n * L) space for the sets.
  • Tests: the example, empty and None fields, one account blocked by email and another by phone, a duplicate followed by an account that reuses its values, lists of different lengths, and Part 2 cases such as " Ana@X.io " and "+1 (415) 555-0100".

Follow-ups

  • Merge duplicates into one person instead of rejecting them, linking accounts that share any email or phone (union-find).
  • Normalize further: Gmail dots and +tags, and phone numbers with and without a country code.
  • Support deleting an account, which frees its email and phone.
  • Run it at scale across many servers, where two sign-ups with the same email can arrive at once.

Where it's asked

  • Airbnb · Coding · Last asked Apr 202645 min · Live coding, one or two rounds, from the same pool as the screen

What it tests

hash set · strings · simulation

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding