This question evaluates implementation-level skills in state management, reversible operation design, and efficient mutable-string handling within the Coding & Algorithms domain.
Implement a text document with undo/redo based on this Python skeleton:
class Operation:
class InsertAtEndOperation(Operation): def init(self, chars_to_insert: str): self.chars_to_insert = chars_to_insert
class DeleteFromEndOperation(Operation): def init(self, num_chars_to_delete: int): self.num_chars_to_delete = num_chars_to_delete
class TextDocument: def init(self) -> None:
def apply_operation(self, op: Operation) -> None:
def get_current_content(self) -> str:
return self.doc
def undo_last(self) -> None:
def redo_last(self) -> None:
Requirements: