← Harvey Interview Insights

Harvey·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Did a technical screen for a Software Engineer role at Harvey. The whole thing was basically one design problem: build an in-memory file system. Not the hardest thing I've done but it required more careful thought about edge cases than I expected.

Questions Asked (1)

Q1

Design and implement an in-memory hierarchical file system with createPath and get operations. createPath should return false if the path already exists, if the parent doesn't exist, or if the path is invalid. get should return -1 for missing paths. Also discuss your data structure choices and the time complexity of each operation.

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

My first instinct was a trie and that turned out to be the right call.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem requirements and constraints, then propose a tree-based data structure where each node represents a path component and stores a value. Implement createPath by validating the path, checking for existence, and ensuring the parent exists before creating the node; implement get by traversing the tree. Discuss time complexity in terms of path length and number of components.

Pro tip: Mention that using a hash map for children allows O(1) lookup per component, and that storing values only at leaf nodes simplifies the design. Also, proactively discuss edge cases like root path and trailing slashes to show thoroughness.

1. Clarify requirements and constraints

Ask about path format (e.g., absolute, components separated by '/'), whether values are integers, and if paths can have trailing slashes. Confirm that createPath should not create intermediate directories.

2. Choose data structure

Propose a trie (prefix tree) where each node represents a path component and has a map of children and an optional value. Explain why this is efficient for hierarchical data and supports fast lookups.

3. Implement createPath

Validate the path (non-empty, starts with '/', no empty components). Split into components, traverse from root, and check if the full path already exists. Ensure the parent exists before creating the final node and setting its value.

4. Implement get

Traverse the tree following the path components. If any component is missing, return -1. If the full path exists and has a value, return it; otherwise return -1.

5. Analyze complexity and trade-offs

State that both operations take O(k) time where k is the number of components in the path, and space is O(total nodes). Discuss alternatives like nested hash maps and their trade-offs.

Key Points to Mention

  • Use a trie (prefix tree) with each node storing a map of children and an optional value.
  • Path validation: must start with '/', no empty components, and no trailing slash unless root.
  • createPath returns false if path exists, parent missing, or invalid; otherwise creates node and returns true.
  • get returns -1 if path missing or no value; otherwise returns the stored value.
  • Time complexity: O(k) for both operations, where k is the number of path components.
  • Space complexity: O(n) where n is total number of nodes created.

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