We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3aea622 commit f70bd78Copy full SHA for f70bd78
1910.py
@@ -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