← Questions

Remove deleted folders and their descendants from a path list

0
SnowflakeCodingLast asked Sep 2025

You get a list of hierarchical paths such as California, California/San Francisco and California/San Francisco/7th Street, and a list of paths to delete. Deleting a path removes it and everything under it. Return the paths that remain.

A trie keyed by path segment is a natural fit. Make sure a deleted path does not remove a sibling that only shares a prefix of characters (for example California/San versus California/San Francisco).

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding