Deduplicate files by size then content hash

0
Sign in

Walk a directory tree and group files with identical content. Compare file sizes first so large files are hashed only when sizes collide, then hash the rest. Be ready to discuss I/O versus CPU cost, hash choice, and how the design changes at very large scale.

def find_duplicates(root):
    """Return sorted groups (sorted lists of 2+ paths) of files with identical bytes under root."""
AnthropicHarveyCodingMediumLast asked Sep 2026

Sign in to see the worked answer

The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.