Censoring
InterviewTime limit1sMemory limit256 MB
Repeatedly delete the first occurrence of T from S, including matches formed by earlier deletions, and print what remains.
- Level
Medium5 of 10
- Topics
- String matching, Stack
- Solved
- No attempts yet
Problem
Farmer John subscribed to a housekeeping magazine so his cows have something to read while they wait to be milked. The latest issue carries an article on cooking the perfect steak, and John would rather his cows never see it.
John concatenated all of the magazine text into a string of length at most . He now wants to censor it by deleting the offending substring . He does it like this. Find the first occurrence of in and delete it. Repeat the same step, always deleting the first remaining occurrence, until no longer occurs in . One deletion can create a new occurrence of that was not there before.
Report the contents of 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 complete. No input makes become empty during the deletion process.