HARDasked at 2 companies

Delete Duplicate Folders in System

A hard-tier problem at 54% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Booking.com and 1 others.

Founder's read

Delete Duplicate Folders in System shows up at Booking.com and Nvidia, and it's a hard problem that trips up most candidates the first time they see it. You're given a file system represented as a 2D array, and you need to delete all folders that are structurally identical to another folder somewhere in the tree. The trap: this isn't about comparing folder names or paths. It's about recognizing that two completely different branches might have identical internal structure, then removing the duplicates. Acceptance sits at 54%, which means half the people who attempt it don't solve it cleanly. If this hits your live assessment and you blank on the serialization trick, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
2
Difficulty
HARD
Acceptance
54%

Companies that ask "Delete Duplicate Folders in System"

If this hits your live OA

Delete Duplicate Folders in System is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The core insight is that you need to serialize the structure of each folder (not its name or location) and use hashing to detect duplicates. Most candidates start by comparing paths or folder names, which fails immediately. The real pattern is a post-order traversal of the tree where you build a unique signature for each folder based on its children and their signatures. You use a Trie or a hash map to track which signatures you've seen, then mark duplicates for deletion. The trick is handling the order of children consistently so that two folders with the same kids in the same structure produce the same hash. Common failure points are forgetting to sort children before hashing, or trying to compare folder structures naively without serialization. This combines Hash Table, Trie, and String topics because you're building compact string representations of tree structures and using hashing to group them. StealthCoder is the hedge for the live OA when the serialization pattern isn't muscle memory yet.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Delete Duplicate Folders in System recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Delete Duplicate Folders in System interview FAQ

Is this really asked at top companies that often?+

It appears in reports from Booking.com and Nvidia, both major infrastructure and backend-heavy companies. It's less frequent than easier problems, but it's a known vaunt problem they use to filter strong candidates. The 54% acceptance rate confirms it's a real blocker for most people.

What's the main trick I'm missing if I can't solve this?+

You need to serialize folder structure as a string or hash, not compare paths. Most people try to compare metadata or use raw folder names. The pattern is post-order traversal with a hash map to detect duplicate signatures. Once you see that pattern, the code becomes mechanical.

Does this involve building an actual Trie?+

Not necessarily. The Trie topic appears in the problem tags because Trie structure mirrors the file system hierarchy conceptually. Most solutions use a hash map to track serialized folder signatures and a post-order DFS. A Trie implementation is overkill for the core logic.

How does the String topic fit here?+

You serialize each folder's structure into a unique string representation, usually something like 'child1,child2,child3' in sorted order. That string becomes your key for detecting duplicates in a hash map. String concatenation and sorting are the mechanics of the solution.

How long does this usually take to code in an interview?+

If you know the serialization pattern, 25 to 35 minutes to code and test cleanly. If you don't, you'll waste 40 minutes on dead-end approaches. The structural insight is the gating factor, not the implementation.

Want the actual problem statement? View "Delete Duplicate Folders in System" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.