← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Implement a TextDocument class that supports appending text, deleting text from the end, and undo/redo of those operations.
Operations:
TextDocument() — initialise an empty document.append(text) — append the string text to the end of the document. Returns None.deleteFromEnd(numChars) — delete the last numChars characters. If the document has fewer than numChars characters, delete everything. A deletion that removed zero characters (empty document) is a no-op and must not be added to the undo stack. Returns None.undo() — undo the most recent append or non-empty deleteFromEnd. If there is nothing to undo, no-op. Returns None.redo() — redo the most recently undone operation. Any new append or deleteFromEnd clears the redo stack. Returns None.getContent() — return the current document contents (a string).Class name: TextDocument (first operation in test_cases).