← HarveyAI Interview Insights

HarveyAI·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Coding round at HarveyAI for a software engineer role. The problem was a spreadsheet cell dependency thing, basically a variant of a well-known design question, and I almost had it but ran out of time one line short.

Questions Asked (1)

Q1

Design a spreadsheet where cells can reference other cells, with the constraint that read operations must be O(1).

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

One line away.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: cells can reference other cells, and reads must be O(1). Propose a design where each cell stores its computed value and a list of dependents; when a cell's value changes, propagate updates to dependents (write-heavy). Discuss trade-offs like handling cycles and memory overhead.

Pro tip: Mention that O(1) reads imply eager evaluation, and that the real challenge is efficient updates—consider topological sorting or DFS with cycle detection to avoid infinite loops.

1. Clarify Requirements

Ask about the expected read/write ratio, whether formulas can change, and if cycles are allowed. This determines the update strategy.

2. Design Data Structures

Each cell stores its value, formula, and a list of dependent cells. Use a graph where nodes are cells and edges represent dependencies.

3. Implement O(1) Reads

Since each cell stores its computed value, reading is just accessing the value field—O(1).

4. Handle Updates

When a cell changes, recompute its value and propagate to dependents using DFS or BFS. Use topological order to ensure correct evaluation.

5. Address Cycles and Errors

Detect cycles during propagation and mark affected cells as errors. Discuss how to handle circular references gracefully.

Key Points to Mention

  • Trade-off between read and write performance: O(1) reads require eager evaluation, making writes potentially O(n) in worst case.
  • Dependency graph representation: adjacency list where each cell points to its dependents.
  • Cycle detection using DFS with visited states (e.g., white/gray/black) to avoid infinite loops.
  • Topological sorting to determine correct update order when multiple cells depend on each other.
  • Memory overhead: storing dependents for each cell increases space complexity.
  • Handling formula changes: when a cell's formula changes, update its dependencies and recompute.

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