Censoring
InterviewTime limit1sMemory limit256 MB
Repeatedly delete the first occurrence of pattern T from string S until none remains and print the result.
- Level
Medium5 of 10
- Topics
- Stack, String matching
- Solved
- No attempts yet
Problem
Farmer John subscribed to a magazine so that his cows have something to read while they wait during milking. The latest issue carries an article on how to cook the perfect steak, and John would rather his cows never see it.
John took every character of the magazine and joined it into one string of length at most . He now wants to censor the text by deleting the places where a string of length at most appears. The procedure is this. Find the first occurrence of in and delete it. Repeat, deleting the first occurrence of each time, until no longer appears in . A deletion joins the two halves around it, so an occurrence of that was not there before can appear.
Determine what is once the censoring is finished.
Input
The first line contains the string . The second line contains the string . The length of is at most the length of , and both and consist only of lower case letters a to z.
Output
Print the string after all deletions are finished. never becomes empty during the process.