Cluster Near-Duplicate Documents by Shared MinHash Bands

Last updated: November 29, 2026

Quick Overview

Each document has a MinHash signature split into bands, one hash per band. Two documents are candidates if they share the same hash in the same band position; return the transitive clusters of documents as sorted lists.

OpenAI
Coding & Algorithms
Software Engineer
OpenAI
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Each document has a MinHash signature split into bands, one hash per band. Two documents are candidates if they share the same hash in the same band position; return the transitive clusters of documents as sorted lists.

Removing near-duplicate web documents is an important step in building pretraining corpora, and locality-sensitive hashing with banded MinHash is the standard technique. In an OpenAI onsite the interviewer wants to see you realize transitive grouping is a union-find problem, avoid comparing all pairs, and know what band collisions mean.

What the Interviewer Expects
  • Key collisions by (band index, hash), not hash alone
  • Union each document with the first owner of a key instead of all pairs
  • Implement union-find with path compression and union by rank
  • Return deterministic cluster ordering
  • Discuss false positives from transitivity and how to verify candidates
Key Topics to Cover
union find
MinHash
locality-sensitive hashing
near-duplicate detection
connected components
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Transitive chaining merges documents that are not similar: how would you verify with Jaccard similarity before unioning?
  • How do the number of bands and rows per band shape the similarity threshold?
  • Signatures are spread across 1,000 machines: how do you run this distributedly?
  • Keep one representative per cluster: which would you choose for training?
Sharpen Your Skills on Codemia

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

Practice DSA Problems
Sample Answer
Requirements
  • Input: doc_id -> [h0, h1, ...], one hash per band.
  • Documents sharing (i, h) for any band i are linked; clusters are connected components.
  • Output: clusters as sorted lists, ordered by their...
High-Level Design

Map each (band, hash) bucket to the first document seen in it. When a later document lands in the same bucket, union it with that first owner. Linking to one representative per bucket is enough for ...


Submit Your Answer
Markdown supported