String Explosion
InterviewTime limit2sMemory limit128 MB
Repeatedly delete every occurrence of the explosion string until none remains, printing FRULA when nothing is left.
- Level
Medium5 of 10
- Topics
- Stack, String matching
- Solved
- No attempts yet
Problem
Sanggeun planted an explosion string inside a longer string. When the explosion string explodes, that part disappears from the string and the pieces on either side join together.
An explosion works like this.
- If the string contains the explosion string, every occurrence of the explosion string explodes. The remaining pieces are joined in order to form a new string.
- The new string may contain the explosion string again.
- The explosions continue until the string no longer contains the explosion string.
Sanggeun wants to know which string is left once every explosion has finished. Sometimes no character is left. In that case, print FRULA.
The explosion string never contains the same character twice.
Input
The first line contains the string. Its length is at least and at most .
The second line contains the explosion string. Its length is at least and at most .
Both strings consist only of lowercase letters, uppercase letters, and the digits through .
Output
Print the string that is left once every explosion has finished. If no character is left, print FRULA.