Find Duplicate Files by Content
Updated
Problem statement
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 <= 1000001 <= paths[i].length <= 3000 <= 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