1910. Remove All Occurrences of a Substring
class Solution:
def removeOccurrences(self, s: str, part: str) -> str:
stk = []
N = len(part)
for i in s:
stk.append(i)
if "".join(stk[-N:]) == part:
for _ in range(N):
stk.pop()
return "".join(stk)