← Harvey Interview Insights

Harvey·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Harvey SE interview, got a multi-part coding problem about building an in-memory spreadsheet from scratch. Three progressive parts, each adding complexity. Felt manageable until cycle detection showed up and I had to think harder than expected.

Questions Asked (1)

Q1

Design and implement an in-memory spreadsheet that supports cell labels like A1 and B10, with set_cell and get_cell methods. Start with plain integer storage, then add formula support (cell references and addition), then add cycle detection.

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

Part 1 was basically a hashmap, took maybe five minutes.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then design a simple cell storage model using a map from labels to values. Implement incrementally: first plain integers, then formulas with dependency tracking, and finally cycle detection using DFS. Discuss trade-offs and test edge cases.

Pro tip: Demonstrate incremental development by writing tests for each stage and explaining how your design evolves. This shows you can build robust systems and communicate technical decisions clearly.

1. Clarify Requirements

Ask about expected operations, formula syntax, error handling, and performance needs. Confirm that cells can contain integers or formulas, and that cycles must be detected.

2. Design Data Structures

Use a hash map to store cell values, where each cell can be an integer or a formula object. For formulas, maintain a dependency graph to track references.

3. Implement Basic Operations

Write set_cell and get_cell for plain integers. Then extend to parse formulas like '=A1+B2', evaluate them recursively, and update dependencies.

4. Add Cycle Detection

During formula evaluation, track visited cells. If a cell is revisited, raise a circular reference error. Use DFS with a recursion stack or visited set.

5. Test and Optimize

Test with edge cases: self-references, indirect cycles, large chains. Discuss caching evaluated results and handling updates to dependencies.

Key Points to Mention

  • Use a map from cell labels (e.g., 'A1') to values or formula objects.
  • Parse formulas to extract cell references and operations (addition).
  • Maintain a dependency graph to know which cells depend on others.
  • Implement cycle detection with DFS, tracking visited cells during evaluation.
  • Handle errors gracefully, such as invalid labels or circular references.
  • Consider performance implications of recursive evaluation and caching.

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