Answered step by step
Verified Expert Solution
Link Copied!

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 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions