The Design Excel Sum Formula interview question is a high-level system design task within a matrix. You need to implement a spreadsheet that supports set(r, c, val) and sum(r, c, cells). A sum cell is reactive: if any of the cells it references change, its own value must be updated. This Design Excel Sum Formula coding problem is a challenge in dependency tracking and graph traversal.
Top companies like OpenAI and Microsoft ask this to evaluate your ability to handle Graph interview patterns, specifically Topological Sort and Directed Acyclic Graphs (DAGs). It tests how you manage recursive dependencies and whether you can prevent infinite loops (circular references). It’s a test of complex object-oriented design.
This problem follows the Dependency Graph pattern.
Map<SourceCell, List<DependentCells>>.set: Change the cell's value and trigger a recursive update (or BFS/DFS) to all dependent cells.sum: Store the formula, calculate the initial value, and update the dependency graph.set(A, 1, 5).sum(B, 1, ["A1"]): B1 is now 5. B1 depends on A1.sum(C, 1, ["A1", "B1"]): C1 is now . C1 depends on A1 and B1.set(A, 1, 2):
Treat each cell as a node in a graph. When a cell changes, you are performing a traversal from that node. If you can explain how to use Caching to avoid redundant work in the update chain, you show strong performance optimization skills.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Design Spreadsheet | Medium | Solve | |
| Find All Possible Recipes from Given Supplies | Medium | Solve | |
| Strange Printer II | Hard | Solve | |
| Build a Matrix With Conditions | Hard | Solve | |
| Design SQL | Medium | Solve |