← LinkedIn Interview Insights

LinkedIn·Software Engineer·Onsite - Coding / Algorithms·Senior

SeniorPrefer not to say
May 2026

Summary

LinkedIn coding round, probably backend or infra-adjacent given the problem. One question but it had enough layers to eat up the whole session.

Questions Asked (1)

Q1

Given a set of deleted file paths and a list of services each with a read and write path, determine which services are affected. A service is affected if its path or a parent directory of its path overlaps with any deleted path. Then convert the full set of paths into a file-tree structure and return only the affected subtrees, excluding sibling subtrees that share the same root but aren't actually affected.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The first part felt manageable, prefix matching on paths.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Clarify requirements and edge cases

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.

2. Determine affected services

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.

3. Build a file tree of all paths

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.

4. Prune unaffected subtrees

Traverse the trie and remove any subtree that contains no affected nodes. Return only the subtrees that have at least one affected node.

5. Return the affected subtrees

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.

Key Points to Mention

  • Trie data structure for efficient prefix matching and tree representation
  • Prefix overlap logic: a path is affected if it is a prefix of a deleted path or vice versa
  • Time and space complexity analysis: O(N * L) where N is number of paths and L is average path length
  • Handling of edge cases: root directory, empty paths, duplicate paths
  • Pruning strategy: post-order traversal to remove unaffected branches
  • Scalability considerations for large file systems and distributed services

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