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

Find Duplicate Files by Content

Microsoft logoMicrosoft● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Data Scientist internship onsite asks candidates to list files in a folder, find files that are the same, and speed up the search for duplicates. We chose a flat list from a recursive listing, equal content as the test of sameness, no symlinks, a fixed grouping, the function signature and the limits.

You are given a flattened recursive folder listing as parallel arrays of unique file paths and exact file contents. Return every group of files that have identical content.

Omit singleton groups. Sort paths inside each group lexicographically, then sort groups by their first path.

Function

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

Examples

Example 1

paths = ["/a/x.txt","/b/y.txt","/a/z.txt","/c/w.txt"]contents = ["hello","same","same","hello"]return = [["/a/x.txt","/c/w.txt"],["/a/z.txt","/b/y.txt"]]

Two content values each occur twice; sorting paths and then groups produces the shown order.

Example 2

paths = ["/a","/b"]contents = ["left","right"]return = []

No two files have identical content.

Constraints

  • 0 <= paths.length = contents.length <= 100000
  • 1 <= paths[i].length <= 300
  • 0 <= contents[i].length <= 10000
  • Paths are unique

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Travelers per Consecutive City TripletUber · ONSITE INTERVIEWUber interview questions
  • 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
  • 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

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[][] findDuplicateFiles(String[] paths, String[] contents) {
      // Write your code here.
    }

}
Checking account…