Skip to content

Commit f70bd78

Browse files
authored
Add files via upload
1 parent 3aea622 commit f70bd78

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

1910.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 1910. Remove All Occurrence of a Substring
2+
class Solution:
3+
def removeOccurrences(self, s: str, part: str) -> str:
4+
stack = [] # To keep track of the characters in s
5+
for char in s:
6+
stack.append(char)
7+
if len(stack) >= len(part) and ''.join(stack[-len(part):]) == part:
8+
# Remove the occurrence of the substring
9+
for i in range(len(part)):
10+
stack.pop()
11+
return ''.join(stack)

0 commit comments

Comments
 (0)