Loading problem…
Implement a TextEditor class that supports INSERT, DELETE, UNDO, and REDO operations. The editor should maintain a history of operations using a stack-based approach.
INSERT(text, position): Insert text at a given positionDELETE(position, length): Delete characters starting at positionUNDO(): Undo the last operationREDO(): Redo the last undone operationgetText(): Return the current text contentconst editor = new TextEditor();
editor.insert('Hello', 0); // text = 'Hello'
editor.insert(' World', 5); // text = 'Hello World'
editor.delete(5, 6); // text = 'Hello'
editor.undo(); // text = 'Hello World'
editor.undo(); // text = 'Hello'
editor.redo(); // text = 'Hello World'