← Harvey Interview Insights

Harvey·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Interviewed for a software engineer role at Harvey and got a spreadsheet engine problem. Pretty meaty for a single coding round, more design-y than I expected.

Questions Asked (1)

Q1

Design and implement a Spreadsheet class where cells can hold either integer literals or formula strings that sum cell references and literals. Support get and set operations, lazy or eager evaluation, and raise an error on cyclic dependencies without modifying existing state.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

The cycle detection part is what bit me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: supported operations, formula syntax, evaluation strategy, and error handling. Then outline a design using a dependency graph and choose lazy evaluation with memoization for efficiency. Finally, discuss cycle detection via DFS and how to maintain state consistency on errors.

Pro tip: Mention that you would use a topological sort or DFS with a recursion stack for cycle detection, and that you would validate the entire formula before committing any changes to ensure atomicity.

1. Clarify Requirements

Ask about the exact formula syntax, supported operations (e.g., SUM), evaluation strategy (lazy vs eager), and error handling expectations.

2. Design Data Structures

Propose storing cell values and formulas in a map, and maintaining a dependency graph (adjacency list) to track relationships between cells.

3. Choose Evaluation Strategy

Decide between lazy and eager evaluation. Lazy with memoization is often simpler and avoids unnecessary computations, but eager can be more predictable.

4. Implement Cycle Detection

Use DFS with a recursion stack to detect cycles when setting a formula or evaluating. Ensure that if a cycle is detected, the state remains unchanged.

5. Handle Errors and State Consistency

On cycle detection, raise an error without modifying existing cell values or dependencies. Validate formulas before applying changes.

Key Points to Mention

  • Dependency graph representation (adjacency list) for tracking cell references.
  • Lazy evaluation with memoization to cache computed values and invalidate on updates.
  • Cycle detection using DFS with a recursion stack or topological sort.
  • Atomic updates: validate formula and check for cycles before committing changes.
  • Error handling: raise specific exceptions for cycles and invalid formulas.
  • Trade-offs between lazy and eager evaluation in terms of performance and complexity.

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