← Questions

Deduplicate account sign-ups by email and phone

0
AirbnbCodingLast asked Apr 2026

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.

Reconstructed from the reported question; details may differ from what interviewers ask.

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