Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String plusOut(String str, String word) {
- String res = "";
- for(int i = 0; i < str.length() - word.length() + 1; i++) {
- if(str.substring(i, i+word.length()).equals(word)) {
- res += word ;
- i += word.length() - 1;
- }
- else { res += "+"; }
- }
- int i = res.length();
- while(i < str.length()) {
- res += "+";
- i++;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement