#C10372. Remove Pattern
Remove Pattern
Remove Pattern
Given a string s
and a pattern p
, remove all non-overlapping occurrences of p
from s
. If p
is an empty string, the string remains unchanged. You need to read the input from stdin and write the output to stdout.
Details:
- Overlapping occurrences are removed in a non-overlapping manner. That is, after an occurrence of
p
is removed froms
, the search continues from the position right after the removed substring. - For example, if
s = "aabbcc"
andp = "ab"
, then the output should be"abcc"
. - Another example: if
s = "aaa"
andp = "aa"
, the output is"a"
because the removal happens in one non-overlapping pass.
inputFormat
The input consists of two lines:
- The first line contains the string
s
. - The second line contains the pattern string
p
.
outputFormat
Output a single line containing the modified string after all occurrences of p
have been removed from s
.
aabbcc
ab
abcc
</p>