7
Back to Problem Dungeon

Text Editor with Undo

medium

Step 1: Requirements

Requirements

Questions to ask

  • What operations? (insert, delete, replace, format)
  • How deep is the undo history? (unlimited, fixed-size)
  • Do we need redo?
  • Do we need multi-cursor support?
  • Is this collaborative (multi-user)?
  • Do we need clipboard (cut/copy/paste)?

Functional requirements

  1. Insert text at a position
  2. Delete a range of text
  3. Replace text in a range
  4. Undo the last operation
  5. Redo a previously undone operation
  6. Copy and paste text
  7. Get the current document content

Non-functional requirements

  • Undo/redo must be O(1)
  • Support documents up to 1MB
  • Operations must be reversible without data loss

1 / 7 — Requirements