Add Undo and Redo to a Prime Video Watchlist Editor

Last updated: November 29, 2026

Quick Overview

Implement add, remove, and reorder operations on a customer's Prime Video watchlist so that any sequence of edits can be undone and redone, using the Command pattern.

Amazon
Software Engineering Fundamentals
Frontend Engineer
Amazon
November 29, 2026
Frontend Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement add, remove, and reorder operations on a customer's Prime Video watchlist so that any sequence of edits can be undone and redone, using the Command pattern.

Watchlist and cart editors on Amazon surfaces let customers fix mistakes quickly, and undo is a classic test of whether you capture enough state to reverse an action. The interviewer checks encapsulation of each action, correct redo invalidation, and handling of no-op commands.

What the Interviewer Expects
  • Wraps each mutation in a command object with execute and undo
  • Captures the state needed for undo at execute time, such as the original index
  • Clears the redo stack when a new command runs
  • Does not record no-op commands on the history
  • Bounds history size
Key Topics to Cover
command pattern
undo/redo
state capture
stacks
encapsulation
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you merge rapid repeated moves into one undo step?
  • How would you sync undo with a server copy edited from another device?
  • How would you persist history across a page reload?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Operations: add a title to the end, remove a title, move a title to an index.
  • undo reverses the last applied edit; redo reapplies the last undone one.
  • A fresh edit after undo discards the re...
High-Level Design

The Watchlist is a plain ordered list. Each Command subclass mutates it in execute and stores what it needs to reverse itself: RemoveTitle remembers the position it removed from, MoveTitle r...


Submit Your Answer
Markdown supported