Cluster Near-Duplicate Photos That Share Any Signature Band
Last updated: November 29, 2026
Quick Overview
Each photo has a MinHash-style signature of equal length, split into a fixed number of bands. Two photos are candidate duplicates if any band matches exactly, and duplicates group transitively. Return the clusters of photo indices.
0
0
0 solved
Each photo has a MinHash-style signature of equal length, split into a fixed number of bands. Two photos are candidate duplicates if any band matches exactly, and duplicates group transitively. Return the clusters of photo indices.
Google Photos groups near-duplicate shots, and locality-sensitive hashing with banding is the standard way to avoid comparing every pair. This onsite question checks that you bucket by band contents with a hash map, union photos that collide, and avoid the quadratic all-pairs scan.
What the Interviewer Expects
- Explains banding and why one matching band suffices as a candidate
- Buckets photos by band contents per band using a hash map
- Unions each photo with the first photo seen in its bucket
- Avoids adding all pairs inside large buckets
- Returns clusters in a deterministic order
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 the number of bands and rows per band to trade precision for recall?
- Transitive chaining can merge two very different photos through a series of near matches. How would you prevent that?
- How would you run this as a MapReduce or Dataflow job?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of signatures (lists of ints, all the same length) and a band count that divides the length.
- Candidate duplicate: any band identical.
- Output: list of clusters, each a sorted list of ...
High-Level Design
For each band, map band contents to the first photo index that had them. When a later photo has the same contents, union it with that first photo. Linking every bucket member to one representative con...