Filter hierarchical paths after deletions | Snowflake
|Home/Coding & Algorithms/Snowflake
Filter hierarchical paths after deletions
Snowflake
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0
Given two arrays:
(
paths — slash-delimited hierarchical strings such as "California", "California/San Francisco", "California/San Francisco/7th Street"; and
(
deletes — paths to remove such as "California/San Francisco". Remove every path that is equal to or a descendant of any path in deletes, and return the remaining paths (order your choice). Design an efficient solution (e.g., Trie or sorting plus prefix-skipping), handle edge cases (duplicates, overlapping deletes, trailing slashes, empty arrays), and analyze time and space complexity. Implement the core function.