Skip to content

Commit c50fecf

Browse files
authored
Create Remove All Occurrences of a Substring.java
1 parent c42f7ed commit c50fecf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public String removeOccurrences(String s, String part) {
3+
while (true) {
4+
int idx = s.indexOf(part);
5+
if (idx == -1) {
6+
break;
7+
}
8+
s = s.substring(0, idx) + s.substring(idx + part.length());
9+
}
10+
return s;
11+
}
12+
}

0 commit comments

Comments
 (0)