Bug Catcher
Time limit1sMemory limit128 MB
For each code line, repeatedly remove the first occurrence of a given bug string until no occurrence remains, then print the result.
- Level
Medium6 of 10
- Topics
- Stack, String, Implementation
- Solved
- No attempts yet
Problem
Not every bug is an insect. Some bugs are a developer's nightmare — the kind people mean when they say "a bug was found in the program you wrote." And as you know, no matter how many you remove, more keep appearing.
Recently a rather handy tool called "Bug Catcher" appeared. It finds and removes every bug in your source code. Your job is to implement this "Bug Catcher": given the source code, keep deleting the string that represents a bug until none remain.
Input
The input consists of several test cases and continues until the end of the file.
Each test case begins with one line containing an integer (), a single space, and a string that represents a bug. The next lines each contain one line of source code from which bugs must be removed.
Each source-code line has length between and characters. The bug string consists of to uppercase English letters. Matching is case-sensitive: only substrings exactly equal to count as bugs.
Output
For each source-code line, repeatedly delete the first occurrence of until no longer appears, and print the resulting line.
No bug may remain in the output. Every other character, including whitespace, must be printed exactly as it appeared in the input.