Leetcode Problem 609. Find Duplicate File in System
609. Find Duplicate File in System
Leetcode Solutions
Using HashMap to Find Duplicate Files
Initialize a HashMap content_to_paths to map file content to a list of file paths.
For each directory info string in the input list:
a. Split the string into the directory path and file info.
b. For each file, extract the file name and content.
c. Append the file path (directory path + file name) to the list in the HashMap corresponding to the file content.
Initialize a list duplicates to store the result.
Iterate over the entries in the HashMap:
a. If an entry has more than one file path, add the list of paths to duplicates.