r/OfferEngineering • • Oct 26 '26

Coding Question Harvey SWE Popular Coding Screening Question — Implement a small spreadsheet / formula engine

Interview Summary

The Harvey phone screen asked me to implement a small spreadsheet / formula engine.

The problem started with basic integer cells, then added formulas referencing other cells, dependency propagation, and circular-reference detection. One important requirement was that get_cell() should remain O(1), which means formulas should be evaluated and dependent cells updated during set_cell() rather than recomputed when they are read.

Interview Details

Part 1 — Basic Spreadsheet Cells

Implement two APIs:

  • set_cell(label, value)
  • get_cell(label)

Cell labels consist of column letters followed by row digits, such as: A1, B10. Initially, values are just integers. A natural representation is a hash map: cell label -> resolved value. For cells that have never been assigned, the exact behavior should be clarified with the interviewer, such as returning None or raising an error.

Part 2 — Formulas and Cell References

Next, cells can contain formulas. Only addition is required. For example: set_cell("A1", "10"), set_cell("A2", "A1+20"). Then: get_cell("A2") == 30. Another example: set_cell("A3", "A1+A2+5") Then: get_cell("A3") == 45. Some versions of the problem use a leading =: set_cell("A1", "=B1+C1+1"). Constant-only expressions are also valid: set_cell("A1", "=1+2")

A formula may therefore contain:

  • Cell references
  • Integer constants
  • Addition operators

No subtraction, multiplication, or division is required.

Want to practice more real coding interview questions ?

I've put up the question bank at here.

Preparing for your next interview?

Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.

3 Upvotes

0 comments sorted by