File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
2025-02-February-LeetCoding-Challenge Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 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 | [ ] ( ) | | |
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 |
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments