Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Note that a new occurrence of pattern can appear if you remove an old one, For example, s = "ababcc" and pattern = "abc".
You can maintain a stack of characters and if the last character of the pattern size in the stack match the pattern remove them