← Snowflake Interview Insights

Snowflake·Software Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Snowflake SWE interview with a path filtering problem that sounds deceptively manageable until you're actually in it trying to talk through edge cases and complexity tradeoffs at the same time.

Questions Asked (1)

Q1

Given a list of slash-delimited hierarchical path strings and a list of paths to delete, remove every path that matches or falls under any delete path. Return the surviving paths. Design an efficient solution, handle edge cases like duplicates and trailing slashes, and analyze time and space complexity.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

My first instinct was to sort both arrays and do prefix-skipping, which works, but I fumbled explaining why that's actually efficient.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and edge cases first, then propose a solution using a trie or hash set for efficient prefix matching. Walk through the algorithm, handle duplicates and trailing slashes, and analyze time and space complexity.

Pro tip: Mention that you would normalize paths by removing trailing slashes and deduplicating inputs before processing, as this simplifies the core algorithm and avoids redundant work.

1. Clarify requirements and edge cases

Ask about input size, whether paths are absolute or relative, how to handle duplicates, trailing slashes, and empty strings. Confirm the expected output format.

2. Choose data structures

Decide between a trie (for prefix matching) and a hash set (for exact matching). Explain trade-offs: trie uses more memory but allows efficient prefix checks; hash set is simpler but requires checking all prefixes.

3. Design the algorithm

Normalize paths, build a trie of delete paths, then traverse each input path to see if it or any ancestor is marked for deletion. Collect surviving paths.

4. Handle edge cases

Address duplicates by deduplicating inputs, trailing slashes by normalizing, and ensure root path deletion works correctly. Consider case sensitivity if relevant.

5. Analyze complexity

State time complexity: O(N * L) where N is number of paths and L is average path length, assuming trie operations are O(L). Space complexity: O(M * L) for the trie, where M is number of delete paths.

Key Points to Mention

  • Normalization: strip trailing slashes and handle empty strings consistently.
  • Deduplication: use a set to avoid processing duplicate paths.
  • Trie vs. hash set: trie enables efficient prefix matching; hash set requires checking all prefixes.
  • Time complexity: O(N * L) for N paths of average length L.
  • Space complexity: O(M * L) for M delete paths in the trie.
  • Edge cases: root path deletion, overlapping delete paths, and paths that are prefixes of others.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.