Find the duplicate accounts of a given Airbnb account.
Each person should have only one account, but people end up with multiple accounts sharing the same email, phone number, government ID, device or other identity information. Given a list of accounts (each named "A", "B", etc.) with identity attributes, build a function that returns the duplicate accounts for any given account. Account names are unique. Example: A, B, C, D with A and D sharing phone 12345 and others linked by shared identifiers gives duplicates of A = [C, D]; adding account E into the chain gives [C, D, E]. Follow-up: what if another identifier such as GovtId is added? Keeping an index per identifier type does not scale. The problem reduces to connected components over accounts linked by any shared identifier; a DSU with a uniqueIdentifier-to-parent map and an account-to-parent map handles new identifier types.
Expect follow-ups like
- What if we add another identifier like GovtId?
Format · Airbnb coding round, 45 minutes plus dry run.
Community answers
Related questions
Given a dataset of numbers, find the duplicates and their counts.Given an array of integers, find the first duplicate.Find the DuplicatesRelated courses


