Collapse Near-Duplicate Marketplace Listings From the Same Seller

Last updated: November 29, 2026

Quick Overview

Sellers on Facebook Marketplace often repost the same item with small title edits. Write Python that groups a seller's listings that have similar titles, prices within 5 percent, and post times within 24 hours, and returns the id of the earliest listing in each group.

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

0

0

0 solved


Sellers on Facebook Marketplace often repost the same item with small title edits. Write Python that groups a seller's listings that have similar titles, prices within 5 percent, and post times within 24 hours, and returns the id of the earliest listing in each group.

Duplicate listings degrade Marketplace search quality, and Meta's onsite data rounds for MLEs include fuzzy dedupe before modeling. The interviewer checks blocking (only compare within seller and time window), a sensible similarity rule, and transitive grouping.

What the Interviewer Expects
  • Blocks comparisons by seller and a sliding time window
  • Normalizes titles into token sets and uses Jaccard similarity
  • Applies relative price tolerance safely, including zero prices
  • Groups transitively with union-find
  • Discusses precision and recall trade-offs of the thresholds
Key Topics to Cover
fuzzy deduplication
blocking
Jaccard similarity
union-find
sliding window
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 choose the Jaccard threshold with labeled data?
  • How would you catch reposts with a different photo but the same item?
  • How do you scale this across all sellers in Spark?
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

Each listing has id, seller_id, title, price, and posted_h (hours since epoch). Duplicates are only within the same seller. I will drop filler words like "for sale", "obo", "like new" before...

Approach

Comparing every pair is quadratic. Blocking cuts it down: group by seller, sort by time, and compare each listing only with earlier ones within 24 hours (two pointers). Pairs that pass all three tests...


Submit Your Answer
Markdown supported