Skip to content

Commit 7f3c2ef

Browse files
committed
Feb 11
1 parent cf6270c commit 7f3c2ef

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

2025-02-February-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| February 08 | [2349. Design a Number Container System](https://leetcode.com/problems/design-a-number-container-system/) | Medium | Solved |
1515
| February 09 | [2364. Count Number of Bad Pairs](https://leetcode.com/problems/count-number-of-bad-pairs/) | Medium | Solved |
1616
| February 10 | [3174. Clear Digits](https://leetcode.com/problems/clear-digits/) | Easy | Solved |
17-
| February 11 | []() | | |
17+
| February 11 | [1910. Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring/) | Medium | Solved |
1818
| February 12 | []() | | |
1919
| February 13 | []() | | |
2020
| February 14 | []() | | |
@@ -38,5 +38,5 @@
3838
| Level | Problems | Solved | Unsolved |
3939
| --- | --- | --- | --- |
4040
| Easy | 6 | 6 | 0 |
41-
| Medium | 4 | 4 | 0 |
41+
| Medium | 5 | 5 | 0 |
4242
| Hard | 0 | 0 | 0 |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def removeOccurrences(self, s: str, part: str) -> str:
3+
stack = []
4+
for ch in s:
5+
stack.append(ch)
6+
if len(stack) >= len(part) and ''.join(stack[-len(part):]) == part:
7+
for _ in range(len(part)):
8+
stack.pop()
9+
return ''.join(stack)
10+
11+
12+
def main():
13+
s = 'daabcbaabcbc'
14+
part = 'abc'
15+
assert Solution().removeOccurrences(s, part) == 'dab'
16+
17+
s = 'axxxxyyyyb'
18+
part = 'xy'
19+
assert Solution().removeOccurrences(s, part) == 'ab'
20+
21+
22+
if __name__ == '__main__':
23+
main()

0 commit comments

Comments
 (0)