FastPrepFind Duplicate File Groups
Problem · Array

Find Duplicate File Groups

MediumAnthropic logoAnthropicFULLTIMEPHONE SCREEN

Problem statement

A filesystem traversal has produced two equal-length arrays. Entry i contains the unique absolute path of one regular file and that file's complete content.

Two files are duplicates exactly when their complete contents are equal. Return every group containing at least two duplicate paths. Sort paths inside a group lexicographically, then sort groups by their first path. Every path contains printable ASCII characters, so lexicographic order compares their ASCII character values from left to right. Return an empty array when no duplicate group exists.

The problem statement continues
Pro

Examples

Example 1

paths = ["/a/x.txt","/b/y.txt","/c/z.txt","/d/w.txt"]contents = ["red","blue","red","blue"]return = [["/a/x.txt","/c/z.txt"],["/b/y.txt","/d/w.txt"]]

The two red files form the first group, and the two blue files form the second. Group order follows each group's first sorted path.

FastPrep Pro
Reported in 1 Anthropic interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Anthropic interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week