Skip to content

Commit 52595fd

Browse files
authored
Create 1910. Remove All Occurrences of a Substring
1 parent 3c1448e commit 52595fd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
string removeOccurrences(string s, string part) {
4+
int n = part.length();
5+
string ans;
6+
for(char c: s){
7+
ans.push_back(c);
8+
while(ans.find(part) < ans.length()){
9+
for(int i = 0;i<n;i++)
10+
ans.pop_back();
11+
}
12+
}
13+
return ans;
14+
}
15+
};

0 commit comments

Comments
 (0)