PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Airtable

Implement undo/redo with two stacks

Last updated: May 3, 2026

Quick Overview

This question evaluates a candidate's ability to design and implement efficient mutable state management and history tracking using data structures (such as stacks), along with string manipulation and algorithmic complexity reasoning.

  • medium
  • Airtable
  • Coding & Algorithms
  • Software Engineer

Implement undo/redo with two stacks

Company: Airtable

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem: Undo/Redo for a Simple Text Editor Design a data structure that simulates a very small text editor with **undo** and **redo**. You are given a sequence of commands; after **each** command, output the current text. ### Commands - `TYPE s`: append string `s` to the end of the current text. - `DELETE k`: delete the last `k` characters (if `k` exceeds current length, delete everything). - `UNDO`: undo the most recent **mutating** command (`TYPE` or `DELETE`) that has not already been undone. - `REDO`: redo the most recent undone command, if no new mutating command has occurred since the undo. ### Notes / Rules - `UNDO`/`REDO` that cannot be applied should do nothing. - Any new `TYPE`/`DELETE` after an `UNDO` clears the redo history. ### Input / Output - **Input:** a list of commands in the format above. - **Output:** the editor text after each command. ### Example Commands: 1. `TYPE abc` 2. `TYPE d` 3. `DELETE 2` 4. `UNDO` 5. `REDO` Outputs: 1. `abc` 2. `abcd` 3. `ab` 4. `abcd` 5. `ab` ### Constraints (typical) - Up to \(2\times 10^5\) commands. - Total typed characters across all `TYPE` commands up to \(2\times 10^5\).

Quick Answer: This question evaluates a candidate's ability to design and implement efficient mutable state management and history tracking using data structures (such as stacks), along with string manipulation and algorithmic complexity reasoning.

Related Interview Questions

  • Count business days excluding holidays - Airtable (medium)
  • Implement spreadsheet undo/redo operations - Airtable (medium)
  • Implement BFS serializer and deserializer - Airtable (Medium)
|Home/Coding & Algorithms/Airtable

Implement undo/redo with two stacks

Airtable logo
Airtable
Jan 22, 2026, 12:00 AM
mediumSoftware EngineerOnsiteCoding & Algorithms
12
0
Practice Read
Loading...

Problem: Undo/Redo for a Simple Text Editor

Design a data structure that simulates a very small text editor with undo and redo.

You are given a sequence of commands; after each command, output the current text.

Commands

  • TYPE s : append string s to the end of the current text.
  • DELETE k : delete the last k characters (if k exceeds current length, delete everything).
  • UNDO : undo the most recent mutating command ( TYPE or DELETE ) that has not already been undone.
  • REDO : redo the most recent undone command, if no new mutating command has occurred since the undo.

Notes / Rules

  • UNDO / REDO that cannot be applied should do nothing.
  • Any new TYPE / DELETE after an UNDO clears the redo history.

Input / Output

  • Input: a list of commands in the format above.
  • Output: the editor text after each command.

Example

Commands:

  1. TYPE abc
  2. TYPE d
  3. DELETE 2
  4. UNDO
  5. REDO

Outputs:

  1. abc
  2. abcd
  3. ab
  4. abcd
  5. ab

Constraints (typical)

  • Up to 2×1052\times 10^52×105 commands.
  • Total typed characters across all TYPE commands up to 2×1052\times 10^52×105 .

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 8,000+ 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.