Merge Duplicate Marketplace Accounts Sharing an Email or Phone

Last updated: November 29, 2026

Quick Overview

Each Facebook Marketplace seller account has a list of contact identifiers. Two accounts belong to the same person if they share any normalized email or phone, directly or through a chain. Return the clusters of account ids.

Meta
Data Manipulation (SQL/Python)
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Each Facebook Marketplace seller account has a list of contact identifiers. Two accounts belong to the same person if they share any normalized email or phone, directly or through a chain. Return the clusters of account ids.

Marketplace integrity teams at Meta link scam accounts that reuse contact details, and this is a Python data question in the coding-heavy data loop. The interviewer is checking transitive grouping with union-find, normalization of messy identifiers, and near-linear complexity.

What the Interviewer Expects
  • Recognizes transitive matching as connected components
  • Implements union-find with path compression or an equivalent BFS
  • Normalizes emails and phones before matching
  • Ignores placeholder or empty identifiers
  • Analyzes time complexity in terms of total identifiers
Key Topics to Cover
union-find
connected components
entity resolution
normalization
deduplication
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you do this in SQL or Spark over billions of rows?
  • How do you stop one shared office phone from merging thousands of unrelated sellers?
  • How would you update clusters incrementally as new accounts arrive?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Input: a list of (account_id, [identifiers]). Identifiers are raw strings: emails with mixed case, Gmail dots and plus tags, and phones in any format. Output: list of clusters, each a sorted list of...

Approach

Map each normalized identifier to the first account that used it. When a later account shows the same identifier, union the two accounts. A chain A shares email with B, B shares phone with C ends up i...


Submit Your Answer
Markdown supported