Find Duplicate Files by Content
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