Skip to content

Commit 886d1c0

Browse files
committed
add 1910
1 parent 1deb8ae commit 886d1c0

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
1910. Remove All Occurrences of a Substring
3+
4+
LeetCode Daily Question for February 10, 2025
5+
6+
Runtime: 0 ms (beats 100.00%)
7+
Memory: 9.22 MB (beats 90.62%)
8+
*/
9+
10+
class Solution {
11+
public:
12+
string& removeOccurrences(string& s, const string& part) {
13+
size_t pos;
14+
while ((pos = s.find(part)) != string::npos) s.erase(pos, part.size());
15+
return s;
16+
}
17+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
1910. Remove All Occurrences of a Substring
3+
4+
LeetCode Daily Question for February 10, 2025
5+
6+
Runtime: 0 ms (beats 100.00%)
7+
Memory: 17.76 MB (beats 75.36%)
8+
"""
9+
10+
class Solution:
11+
def removeOccurrences(self, s: str, part: str) -> str:
12+
while (pos := s.find(part)) != -1:
13+
s = s[:pos] + s[pos + len(part):]
14+
return s

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy