← HarveyAI Interview Insights

HarveyAI·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Coding round at HarveyAI for a software engineer role. It was a twist on a known spreadsheet-style LeetCode problem, which I thought I had seen before until the follow-up hit.

Questions Asked (2)

Q1

Design a spreadsheet cell system where setCell can accept either a plain integer or a formula referencing other cells.

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

Recognized it as a variant of a spreadsheet problem I'd practiced before, so I felt decent going in.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: what formula syntax, error handling, and performance expectations exist. Then propose a design that parses formulas into a dependency graph, uses topological sorting or DFS with memoization for evaluation, and handles cycles. Discuss trade-offs between eager vs lazy evaluation and how to support updates efficiently.

Pro tip: Mention that you would use a directed acyclic graph (DAG) to represent dependencies and detect cycles, and that you'd cache computed values to avoid redundant calculations. This shows you understand both correctness and performance.

1. Clarify Requirements

Ask about formula syntax, supported operations, error handling, and whether cells can be updated. Confirm if evaluation should be eager or lazy.

2. Design Data Structures

Propose storing each cell's raw content (integer or formula) and a dependency graph. Use a map from cell ID to its dependencies and dependents.

3. Implement Evaluation

Describe parsing formulas, resolving references recursively with memoization, and detecting cycles using DFS with visited states.

4. Handle Updates

Explain how to update a cell and propagate changes: either recompute all dependents or use lazy invalidation with caching.

5. Discuss Trade-offs

Compare eager vs lazy evaluation, memory vs computation, and how to handle errors like division by zero or circular references.

Key Points to Mention

  • Dependency graph representation (adjacency list) for cells and formulas
  • Cycle detection using DFS with recursion stack or topological sort
  • Memoization/caching of computed values to avoid redundant evaluation
  • Eager vs lazy evaluation strategies and their performance implications
  • Error handling for invalid formulas, circular references, and division by zero
  • Scalability considerations for large spreadsheets (e.g., incremental updates)

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

Q2

Follow-up: how would you detect a circular dependency between formulas, for example if A1 references B1 and C1, and C1 references back to A1?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I felt the pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the formulas as a directed graph where each cell is a node and dependencies are edges, then detect cycles using DFS with recursion stack or topological sort. Explain the algorithm clearly, discuss trade-offs like time/space complexity, and mention how to handle dynamic updates in a spreadsheet context.

Pro tip: Mention that you can detect cycles incrementally as dependencies are added, which is more efficient than re-checking the entire graph after every change—this shows you think about real-world performance in an interactive system.

1. Model as a graph

Represent each cell as a node and each reference as a directed edge from the referencing cell to the referenced cell. This transforms the problem into cycle detection in a directed graph.

2. Choose a detection algorithm

Use DFS with a recursion stack (colors: white, gray, black) or Kahn's topological sort. Both run in O(V+E) time, where V is the number of cells and E is the number of references.

3. Handle dynamic updates

For a live spreadsheet, maintain the graph incrementally: when a formula changes, update edges and re-run cycle detection only on the affected subgraph, or use a union-find structure if dependencies are only added.

4. Discuss trade-offs and edge cases

Compare DFS vs. topological sort: DFS is simpler for cycle detection, while topological sort also gives evaluation order. Mention self-references (A1 -> A1) and indirect cycles of any length.

Key Points to Mention

  • Directed graph representation of cell dependencies
  • DFS with recursion stack (or three-color marking) for cycle detection
  • Topological sorting (Kahn's algorithm) as an alternative
  • Time and space complexity: O(V+E) time, O(V) space
  • Incremental cycle detection for dynamic updates
  • Handling self-references and reporting the cycle path

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