← 返回 anthropic 的题目列表Find Duplicate Files in a System
类型:online_judge
Given a list of directory paths, each containing a list of files. Each file is formatted as '(content)'. Find and return the paths of all duplicate files.
Requirements:
Use dictionaries and lists to store file content and their paths.
Traverse the filesystem to find all duplicate files.
Output lists of file paths that have the same content.
Example Input:
"root/a 1.txt(abcd) 2.txt(efgh)"
"root/c 3.txt(abcd)"
"root/c/d 4.txt(efgh)"
"root 4.txt(efgh)"
Example Output:
[["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
Test cases:
Input: Directory structure with different contents
Input: Directory structure with same names but different contents
Input: Directory structure with identical contents
Input: Single directory with no duplicates
Input: Multiple directories with possible duplicates
Example
Input
"root/a 1.txt(qwerty) 2.txt(asdfg)"
"root/c 3.txt(qwerty)"