I'll give you a coding exercise. You have to build a text editor with features like insertion where it inserts a text. A feature like the deletion of n characters before the cursor position. another feature that is undo to revert the last operation and another feature which is redo to reapply the last undone operation. The cursor is always at the end of the text after an insertion or deletion, any previous and operation operations cannot be redone.
Asked in the 25-minute coding assessment stage. Implement text_editor(operations), where each operation is a dictionary: {"type":"insert","text":"..."}, {"type":"delete","n":k}, {"type":"undo"}, or {"type":"redo"}. Return the final text. A new insertion or deletion clears the redo history. Example: insert abc, delete 1, undo returns abc; redo returns ab. Constraints: at most 10^5 operations, and deletion removes up to n existing characters.
def text_editor(operations):