FastPrepFind Duplicate Files by Content
Problems/Find Duplicate Files by Content

Find Duplicate Files by Content

Dropbox logoDropbox● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for a feature that finds duplicate files after walking through a directory tree. It does not say what the input and the result look like. This version groups files with exactly the same contents and lists paths in a fixed order. Our version is about 86% the same as the reported question.

You have enumerated the files in a directory hierarchy. The parallel arrays paths and contents describe those files: contents[i] is the complete content of the file at paths[i].

Find every group of duplicate files. Two files are duplicates exactly when their complete content strings are equal.

Return only groups containing at least two paths. Sort the paths inside each group lexicographically, then sort the groups lexicographically by their first path. Files with unique content do not appear in the result.

Function

findDuplicateFiles(paths: String[], contents: String[]) → String[][]

Examples

Example 1

paths = ["/docs/a.txt","/docs/archive/b.txt","/images/c.png","/tmp/d.txt"]contents = ["draft","draft","pixels","draft"]return = [["/docs/a.txt","/docs/archive/b.txt","/tmp/d.txt"]]

The three text files contain the exact string draft. The image content is unique, so its path is omitted.

Example 2

paths = ["/b/y","/a/x","/d/r","/a/z","/c/q"]contents = ["blue","red","solo","blue","red"]return = [["/a/x","/c/q"],["/a/z","/b/y"]]

There are two duplicate groups. Sorting each group puts its paths in lexical order; comparing the first paths places the red group before the blue group.

Constraints

  • 1 <= paths.length <= 2 * 10^5
  • contents.length == paths.length
  • Every path is a unique non-empty absolute path.
  • Each content string has length at most 10^4 and may be empty.
  • The total number of characters across paths and contents is at most 2 * 10^6.
  • Content comparison is exact and case-sensitive.

More Dropbox interview questions

  • Reusable Number AllocatorONSITE INTERVIEW · Seen Feb 2021
  • Remove Redundant Directory GrantsPHONE SCREEN · Seen Feb 2021

Similar questions at other companies

  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
  • Group AnagramsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Most Frequent Call Stack Per ThreadRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Build an Inverted Document IndexConfluent · ONSITE INTERVIEWConfluent interview questions
  • Find Duplicate Element PairsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
All Dropbox interview questionsSee Dropbox hiring insights
Saved
class Solution {
    public String[][] findDuplicateFiles(String[] paths, String[] contents) {
        // Write your code here.
    }
}
Checking account…