← Fuse Energy Interview Insights

Fuse Energy·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Fuse Energy had me extend a mini spreadsheet coding problem I'd apparently already done in a prior round, this time adding undo functionality. Felt like a reasonable follow-up but the history stack part tripped me up more than I expected.

Questions Asked (1)

Q1

You have a mini spreadsheet supporting Set, Get, and SUM operations. Now add an UNDO command that reverts the most recent Set or SUM operation, restoring both the cell's previous value and its formula state using a history stack.

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

The core Set/Get/SUM part was fine since I'd seen it before.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the existing data model and operation semantics, then design an undo mechanism using a history stack that records enough state to revert both value and formula. Discuss trade-offs between storing full snapshots versus deltas, and walk through the implementation of undo for Set and SUM operations.

Pro tip: Mention that you would encapsulate each operation as a command object with an undo method, which makes the design extensible and testable. Also, proactively discuss edge cases like undoing when history is empty or handling dependencies between cells.

1. Clarify requirements and assumptions

Ask questions to understand the spreadsheet's data model, how Set and SUM work, and what 'formula state' means. Confirm whether undo should revert only the most recent operation or support multiple undos.

2. Design the history stack

Propose a stack data structure to store operation records. Each record should contain the necessary information to undo the operation, such as the cell reference, previous value, and previous formula.

3. Define operation records

For Set, store the cell's previous value and formula. For SUM, store the affected cells and their previous values/formulas. Consider using a command pattern where each operation knows how to undo itself.

4. Implement undo logic

When UNDO is called, pop the most recent operation from the stack and apply its inverse: restore the previous value and formula state. Handle edge cases like empty stack or operations that affect multiple cells.

5. Discuss trade-offs and extensions

Compare storing full snapshots versus deltas in terms of memory and complexity. Mention potential extensions like redo, grouping operations, or persisting history.

Key Points to Mention

  • Use a stack (LIFO) to track operations for undo.
  • Store sufficient state to revert both value and formula (e.g., previous value and formula).
  • Consider the command pattern to encapsulate operations and their undo logic.
  • Handle edge cases: empty history, undoing a SUM that affected multiple cells, and dependencies.
  • Trade-offs: memory usage of snapshots vs. deltas, and time complexity of undo.
  • Extensibility: support for redo, transaction grouping, and persistence.

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