Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public boolean prefixAgain(String str, int n) {
  2. return (str.replaceFirst(Character.toString(str.charAt(n-1)),"").contains(Character.toString(str.charAt(n-1))));
  3. }
  4.  
  5. prefixAgain("abcccccbx", 2);
  6.  
  7. public boolean prefixAgain(String str, int n) {
  8. boolean result = false;
  9. if (n < str.length() &&
  10. (str.substring(1)).indexOf(str.substring(0,n)) > -1
  11. ) {
  12. result = true;
  13. }
  14. return result;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement