Group Near-Duplicate Documents With MinHash and Union-Find
Last updated: November 29, 2026
Quick Overview
Given a dictionary of document id to text, return groups of documents whose word 3-gram shingle sets have Jaccard similarity of at least a threshold, using MinHash with locality-sensitive banding to avoid comparing every pair.
Concentric Ai
November 29, 20260
0
0 solved
Given a dictionary of document id to text, return groups of documents whose word 3-gram shingle sets have Jaccard similarity of at least a threshold, using MinHash with locality-sensitive banding to avoid comparing every pair.
Enterprises keep dozens of copies and versions of the same contract or customer list across shares and SaaS apps, and a data security platform like Concentric AI needs to know when a sensitive original has spread. The interviewer probes whether the candidate knows how to make similarity search sub-quadratic and still verify candidates exactly.
What the Interviewer Expects
- Define shingles and Jaccard similarity precisely
- Explain why MinHash approximates Jaccard
- Use banding to generate candidate pairs only
- Verify candidates with exact Jaccard to remove false positives
- Merge transitive matches with union-find
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How do you choose bands and rows for a target threshold?
- What happens to chained groups where A~B and B~C but A and C differ a lot?
- How would you scale this to a billion documents across tenants?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Docs are text; similarity is Jaccard over lowercase word 3-grams. Output groups (size at least 2) of transitively connected near duplicates at threshold. All pairs is O(n^2), too slow for millions o...
High-Level Design
- Shingle each document. 2. MinHash signature of length
num_perm, where each position is the minimum of a seeded hash over shingles; P(two minima equal) equals Jaccard. 3. Split the signature into ...