Merge Duplicate CRM Contacts

Hard ⏱ 18 min 38% acceptance ★★★★★ 4.8
Contacts share an identity when they share an email (case-insensitive). Write merge_contacts(contacts) where each is {'email', 'name', 'phone'} (phone may be None): keep the FIRST occurrence's name, fill a missing phone from any later duplicate, and return the merged list in first-seen order.

Examples

Example 1
Input
merge_contacts([{'email': 'A@x.com', 'name': 'Asha', 'phone': None}, {'email': 'a@x.com', 'name': 'A. Rao', 'phone': '981'}])
Output
[{'email': 'a@x.com', 'name': 'Asha', 'phone': '981'}]
Explanation

One identity: first name kept, phone backfilled.

Constraints

  • Email lowered for identity AND in the output.
  • First-seen name wins; phone backfills only if missing.

Topics

Business Logicdedup + merge

Companies

SalesforceHubSpotZoho

Hints

Hint 1

A dict keyed by lowered email, plus an order list.

Hint 2

Only overwrite phone when the stored one is None.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.