Dsa
Hashing
Medium
File System Deduplicator
In a cloud storage system, a folder is considered a duplicate if it contains exactly the same set of file hashes as another folder, regardless of file names. You are given a list of files and their containing folders along with the hash of each file's content. A folder's identity is defined by the collection of hashes it contains. Count how many folders have at least one other folder that is identical to them.
Input Format:
The first line is N, the number of files. The next N lines contain 'folder_name file_hash' (where file_hash is an integer).
Output Format:
Print the count of folders that are NOT unique (i.e., their content set exists in at least one other folder).
Example:
Input:
4
root 12345
root 67890
backup 12345
backup 67890
Output:
2
(Note: both 'root' and 'backup' contain {12345, 67890})
Key concepts
hashingcollection-hashingfile-systems
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now