Group Duplicate Pin Uploads by Content Hash and Upload Time
Last updated: November 29, 2026
Quick Overview
Given a list of Pin uploads as (pin_id, content_hash, upload_ts), return every group of Pins that share the same image hash. Order each group by upload time so the first entry is the canonical original, and order groups by their earliest upload.
0
0
0 solved
Given a list of Pin uploads as (pin_id, content_hash, upload_ts), return every group of Pins that share the same image hash. Order each group by upload time so the first entry is the canonical original, and order groups by their earliest upload.
Pinterest sees the same image re-pinned and re-uploaded constantly, so duplicate detection by content hash is a natural warm-up in the phone screen. The interviewer checks that you reach for a hash map quickly, define a deterministic order, and talk about what the canonical Pin means downstream.
What the Interviewer Expects
- Uses a dictionary keyed by hash for a single linear pass
- Defines a deterministic tie-break when two uploads share a timestamp
- Filters out singleton hashes rather than returning them
- States time and space complexity correctly
- Mentions that exact hashes miss near-duplicates and how a perceptual hash would change things
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 would you handle near-duplicate images that differ by a resize or crop?
- If uploads arrive as a stream, how would you emit a duplicate alert as soon as the second copy appears?
- How would you shard this across machines if there were billions of uploads?
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 tuples (pin_id, content_hash, upload_ts). Pin ids are unique.
- Output: list of groups; only hashes with 2 or more Pins count as duplicates.
- Inside a group, the earliest upload come...
High-Level Design
One pass buckets uploads by hash. Then each bucket with at least two members is sorted by (timestamp, pin_id). Finally the list of groups is sorted by each group's first element. Because the tuples ar...