Remove Sub-Folders from the Filesystem

Medium · Trie · about 15 minutes

Asked at Google, Amazon, Meta, Microsoft.

Given a list of folder paths (like "/a/b"), remove every folder that is a sub-folder of another listed folder ("/a/b" is a sub-folder of "/a", but "/ab" is not). Return the remaining folders in any order.

Related guides