Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Sep 25th, 2018 67 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. /*
  2.  * this one is lisa's solution with a small change
  3.  */
  4. public String wordEnds(String str, String word) {
  5.   StringBuffer out = new StringBuffer ();
  6.   int s_l = str.length(), w_l = word.length();
  7.   for (int i = 0; i < s_l-w_l+1; i++) {
  8.     if (str.startsWith(word, i)) {
  9.       if (i > 0) out.append(str.charAt(i-1));
  10.       if (i+w_l < s_l) out.append(str.charAt(i+w_l));
  11.     }
  12.   }
  13.   return out.toString();
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top