Design Contact Sync and Prospective User Discovery
Design contact replacement and list non-users with the number of platform users who have each phone number in their contacts.
Build an in-memory service with syncContacts(userId: string, phoneNumbers: string[]): void, which replaces the stored contacts for the registered user whenever the app opens, and prospectiveUsers(userId), which lists phone numbers in that user's contacts that are not registered.
Each result also includes friendsOnPlatform: the number of registered users whose stored contact lists contain that phone number. Assume isRegisteredUser(phoneNumber) is available.
For this exercise, assume phone numbers use one consistent normalization rule, invalid input rejects the entire sync before mutation, duplicates collapse, an empty snapshot clears prior contacts, results sort by normalized phone number, and replaying the same complete snapshot changes no count.
Design the model and contracts, then implement synchronization and query behavior.