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
November 29, 20260
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
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- 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 ProblemsSample Answer
Requirements
- Operations: add a title to the end, remove a title, move a title to an index.
undoreverses the last applied edit;redoreapplies 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...