Simple Text Editor HackerRank Solution in Java with Explanation Problem Description : Implement a simple text editor. The editor initially contains an empty string S. Perform Q operations of the following 4 types: append (W) - Append string W to the end of S. delete (k) - Delete the last K characters of S. print (k) - Print the kth character of S. undo () - Undo the last (not previously undone) operation of type 1 or 2, reverting S to the state it was in prior to that operation. Example : Input : S = "abcde" Operations = ["1 fg", "3 6", "2 5", "4", "3 7", "4", "3 4"] index S ops[index] explanation ----- ------ ---------- ----------- 0 abcde 1 fg append fg 1 abcdefg 3 6 print the 6th letter - f 2 abcdefg 2 5 delete the last 5 letters 3 ab 4 undo the last operation, index 2 4 abcdefg 3 7
Welcome To Programming Tutorial. Here i share about Java Programming stuff. I share Java stuff with simple examples.