Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. public  String plusOut(String str, String word) {
  2.     String res = "";
  3.     for(int i = 0; i < str.length() - word.length() + 1; i++) {
  4.       if(str.substring(i, i+word.length()).equals(word)) {
  5.         res += word ;
  6.         i += word.length() - 1;
  7.       }
  8.       else { res += "+"; }
  9.     }
  10.     int i = res.length();
  11.     while(i < str.length()) {
  12.       res += "+";
  13.       i++;
  14.     }
  15.     return res;
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement