The first part felt manageable, prefix matching on paths.
Model the file system as a trie and use prefix matching to determine affected services. For each service, check if its read or write path is a prefix of any deleted path or vice versa. Then, build a trie of all paths and prune unaffected branches, returning only the subtrees that contain affected paths.
Pro tip: Clarify edge cases upfront, such as whether paths are case-sensitive, whether trailing slashes matter, and how to handle overlapping deletions. This shows attention to detail and prevents incorrect assumptions.
Ask about path format, case sensitivity, and whether deleted paths include directories or files. Confirm that a service is affected if any of its paths overlap with a deleted path.
For each service, check if its read or write path is a prefix of any deleted path or if any deleted path is a prefix of its path. Use a trie or sorting for efficiency.
Construct a trie representing the entire file system from the given paths (deleted and service paths). Mark nodes that correspond to deleted paths or affected service paths.
Traverse the trie and remove any subtree that contains no affected nodes. Return only the subtrees that have at least one affected node.
Serialize the pruned trie into a list of paths or a tree structure, ensuring that sibling subtrees sharing the same root but unaffected are excluded.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.