Question: The program must accept a string S and Q queries as the input Thequery can be S + X or X + S where X
The program must accept a string S and Q queries as the input Thequery can be SX or XS where X is an integer. For each query, theprogram must modify the string S based on the following conditions.If the query is SX then the program must append the last X charactersto the same string. If the query is XS then the program must prepend the first Xcharacters to the same string.Finally, the program must print the modified string S as the output.Note: If there are no X characters in S to perfor the append or prependoperation, then consider the entire string to perform the operation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
