Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 : input: aa input: wabsbdwasbajsud input: Output: aaab Explanation: First, Ralph typed aa as the initial string, then as the operation was 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 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 character to get aaab. Example : input: bbhfg input: 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, copypasting and cutpasting. 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 he has to type in the next characters in the operation string until the next operation is encountered. If the operation is he has to delete characters which he last typed. If the operation is he has to undo the last operation he performed. You have to find the final string which was typed by Ralph. Input Specification: input: The initial string Ralph had to type input: The operation string input: used in operation Output Specification: Return the final string Ralph typed.
Output Specification:
Return the final string Ralph typed.
Example :
input: aa
input: wabsbdwasbajsud
input:
Output: aaab
Explanation:
First, Ralph typed aa as the initial string, then as the operation was 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 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
character to get aaab.
Example :
input: bbhfg
input: 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, copypasting and cutpasting. 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 he has to type in the next characters in the operation string until
the next operation is encountered.
If the operation is he has to delete characters which he last typed.
If the operation is he has to undo the last operation he performed.
You have to find the final string which was typed by Ralph.
Input Specification:
input: The initial string Ralph had to type
input: The operation string
input: used in operation
Output Specification:
Return the final string Ralph typed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started