PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Harvey

Implement Spreadsheet Cell Updates

Last updated: May 15, 2026

Quick Overview

This question evaluates skills in data structures, expression parsing, dependency graph management, incremental evaluation, and cycle detection for maintaining consistent spreadsheet state.

  • hard
  • Harvey
  • Coding & Algorithms
  • Software Engineer

Implement Spreadsheet Cell Updates

Company: Harvey

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Design and implement a small spreadsheet engine that supports setting and reading cell values. A cell name is a string such as `"A1"`, `"B12"`, or `"AA3"`. Each cell can store either an integer value or a formula string. Implement the following operations: ```text setCell(cellName, value) getCell(cellName) -> int ``` Requirements: 1. **Integer-only version** - Initially, `setCell` may receive only integer values. - `getCell` should return the current integer value of the cell. - Choose an appropriate data structure to store cell values. 2. **Formula support** - Extend `setCell` so that `value` can also be a formula string. - A formula always starts with `=`. - Formulas contain only addition using `+`. - Each term is either an integer literal or another cell reference. - There is no subtraction, multiplication, division, modulus, parentheses, or operator precedence beyond left-to-right addition. Example: ```text setCell("B1", 10) setCell("A1", "=B1+5") getCell("A1") -> 15 ``` 3. **Dependency updates** - If a cell changes, all cells that depend on it, directly or indirectly, should reflect the updated value. Example: ```text setCell("B1", 10) setCell("A1", "=B1+5") setCell("B1", 20) getCell("A1") -> 25 ``` 4. **Circular dependency detection** - Detect circular dependencies when setting a formula. - Direct and indirect cycles should both be rejected. Example: ```text setCell("A1", "=B1+1") setCell("B1", "=A1+1") // should be rejected because it creates a cycle ``` Assume undefined referenced cells have value `0`, unless you choose to explicitly reject references to undefined cells. State your choice clearly.

Quick Answer: This question evaluates skills in data structures, expression parsing, dependency graph management, incremental evaluation, and cycle detection for maintaining consistent spreadsheet state.

Related Interview Questions

  • In-Memory File System: Create, Track Duplicates, and List - Harvey (medium)
  • Spreadsheet Formula Engine with Cycle Detection - Harvey (medium)
  • Design an In-Memory Spreadsheet Engine - Harvey (hard)
  • Implement a Spreadsheet With Formulas - Harvey (medium)
  • Evaluate Symbol Expressions - Harvey (medium)
|Home/Coding & Algorithms/Harvey

Implement Spreadsheet Cell Updates

Harvey logo
Harvey
May 9, 2026, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
2
0
Practice Read
Loading...

Design and implement a small spreadsheet engine that supports setting and reading cell values.

A cell name is a string such as "A1", "B12", or "AA3". Each cell can store either an integer value or a formula string.

Implement the following operations:

setCell(cellName, value)
getCell(cellName) -> int

Requirements:

  1. Integer-only version
    • Initially, setCell may receive only integer values.
    • getCell should return the current integer value of the cell.
    • Choose an appropriate data structure to store cell values.
  2. Formula support
    • Extend setCell so that value can also be a formula string.
    • A formula always starts with = .
    • Formulas contain only addition using + .
    • Each term is either an integer literal or another cell reference.
    • There is no subtraction, multiplication, division, modulus, parentheses, or operator precedence beyond left-to-right addition.
    Example:
    setCell("B1", 10)
    setCell("A1", "=B1+5")
    getCell("A1") -> 15
    
  3. Dependency updates
    • If a cell changes, all cells that depend on it, directly or indirectly, should reflect the updated value.
    Example:
    setCell("B1", 10)
    setCell("A1", "=B1+5")
    setCell("B1", 20)
    getCell("A1") -> 25
    
  4. Circular dependency detection
    • Detect circular dependencies when setting a formula.
    • Direct and indirect cycles should both be rejected.
    Example:
    setCell("A1", "=B1+1")
    setCell("B1", "=A1+1")  // should be rejected because it creates a cycle
    

Assume undefined referenced cells have value 0, unless you choose to explicitly reject references to undefined cells. State your choice clearly.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Harvey•More Software Engineer•Harvey Software Engineer•Harvey Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.