The Design Spreadsheet coding problem asks you to implement a basic spreadsheet application. You need to support setting cell values (which can be integers), summing ranges of cells, and retrieving cell values. The most challenging part is that a cell can contain a formula (a sum of other cells), and if the values of those source cells change, the formula cell must reflect the new total when retrieved.
Microsoft and Rippling ask this to test your understanding of dependency management and lazy vs. eager evaluation. It evaluates how you model relationships between data points. This problem is essentially a graph problem in disguise, checking if you can detect cycles (circular dependencies) and how you handle recursive calculations.
This problem uses a Matrix (or 2D Array) combined with a Hash Table to store formulas.
ValueNode object at each grid position that stores either a raw value or a formula (a list of cell ranges).get is called, if the cell contains a formula, recursively calculate the sum of its dependencies.Spreadsheet .
A1 + A2. It returns 15.Be prepared to discuss "Eager" vs "Lazy" evaluation. Eager evaluation updates all formula cells immediately when a dependency changes, while Lazy evaluation only calculates the value when get is called. Each has different trade-offs regarding update speed vs. read speed.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Design SQL | Medium | Solve | |
| Match Alphanumerical Pattern in Matrix I | Medium | Solve | |
| Unique Word Abbreviation | Medium | Solve | |
| Design Excel Sum Formula | Hard | Solve | |
| Design Tic-Tac-Toe | Medium | Solve |