Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 886d1c0

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

2 files changed

+31
-0
lines changed
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+
};
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)