Skip to main content
All Questions

Implement undo() and redo() for set_cell on a Table class.

Unlock detailed company stats for this questionUpgrade

In an Airtable app you can create grid components, like spreadsheets, with columns, rows and cells; updates support undo/redo. You are given a Table class with filled-out functions. The table is represented internally as a 2D dict, e.g. {row1: {col1: value1, col2: value2}}, with a row_ids array and a column_ids array.

Functions: add_column, remove_column, add_row(row_id), remove_row(row_id), set_cell(row, col, value), get_cell(row, col), get_row_ids(), get_column_ids(). They already handle key errors by raising exceptions.

Iteration 1: implement undo() and redo() for the set_cell case. You may not add parameters to undo() or redo() (think about why, given the product context).

Test: table = Table() table.add_row("test_row") table.add_column("test_col") table.set_cell("test_row", "test_col", "initial_value") table.set_cell("test_row", "test_col", "changed_value") table.undo() # get_cell returns "initial_value" table.redo() # get_cell returns "changed_value"

Iteration 2 (not reached): extend undo()/redo() to add_row, remove_row, add_column and remove_column. The interviewer and candidate aligned on a diff-history approach to save space, and the candidate wrote test cases.

Expect follow-ups like

  • Iteration 2: extend undo() and redo() to the other operations (add_row, remove_row, add_column, remove_column).

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.