Question: Output Specification: Return the final string Ralph typed. Example 1 : input 1 : aa input 2 : wabsbdwasbajsud input 3 : 1 Output: aaab

Output Specification:
Return the final string Ralph typed.
Example 1:
input1: aa
input2: wabsbdwasbajsud
input3: 1
Output: aaab
Explanation:
First, Ralph typed aa as the initial string, then as the operation was w, he typed the
characters which appeared in the operation string, until he was given the next operation.
So he typed: aaabsb.
Next, he had to delete 1 character, so he deleted 'b' to get: aaabs.
For the next operation, again he had to type characters and so he wrote: aaabsasbajs.
Next, he had to perform undo, which meant he got aaabs and finally he deleted 1
character to get aaab.
Example 2:
input1: bbhfg
input2: wbsydwtreaxcbuwsasxasdRalph and Typing Test
Ralph is learning how to type fast and use some of the shortcuts provided by the
keyboard such as undoing a previous operation, copy-pasting and cut-pasting. Now, he
has completed the course and is appearing for his final exam. In the exam, he is given
some operations to perform over a string.
He is given two strings, one he has to type and the other string is the operations that he
has to perform. The three major operations that he needs to perform are:
If the operation is w, he has to type in the next characters in the operation string until
the next operation is encountered.
If the operation is d, he has to delete 'N' characters which he last typed.
If the operation is u, he has to undo the last operation he performed.
You have to find the final string which was typed by Ralph.
Input Specification:
input1: The initial string Ralph had to type
input2: The operation string
input3: 'N', used in operation 2
Output Specification:
Return the final string Ralph typed.
 Output Specification: Return the final string Ralph typed. Example 1: input1:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!