Design and implement a text editor supporting insert(string), print(x), left(x), right(x), backspace(x) and delete(x) with cursor movement.
Asked in the DSA round 1 stage.
Implement text_editor(operations). The document initially is empty and the cursor is at position zero. insert(s) inserts s at the cursor and moves the cursor after it. left(x) and right(x) move the cursor by up to x characters. backspace(x) removes up to x characters before the cursor, while delete(x) removes up to x characters after it. print(x) returns the next up to x characters after the cursor. Return all print results in order.
def text_editor(operations):