Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,4 @@
public static boolean pali(String testMe){
StringBuilder sb = new StringBuilder(testMe);
return testMe.equals(sb.reverse().toString());
}

View file

@ -0,0 +1,19 @@
public static boolean isPalindrome(String input) {
for (int i = 0, j = input.length() - 1; i < j; i++, j--) {
char startChar = input.charAt(i);
char endChar = input.charAt(j);
// Handle surrogate pairs in UTF-16
if (Character.isLowSurrogate(endChar)) {
if (startChar != input.charAt(--j)) {
return false;
}
if (input.charAt(++i) != endChar) {
return false;
}
} else if (startChar != endChar) {
return false;
}
}
return true;
}

View file

@ -0,0 +1,9 @@
public static boolean rPali(String testMe){
if(testMe.length()<=1){
return true;
}
if(!(testMe.charAt(0)+"").equals(testMe.charAt(testMe.length()-1)+"")){
return false;
}
return rPali(testMe.substring(1, testMe.length()-1));
}

View file

@ -0,0 +1,14 @@
public static boolean rPali(String testMe){
int strLen = testMe.length();
return rPaliHelp(testMe, strLen-1, strLen/2, 0);
}
public static boolean rPaliHelp(String testMe, int strLen, int testLen, int index){
if(index > testLen){
return true;
}
if(testMe.charAt(index) != testMe.charAt(strLen-index)){
return false;
}
return rPaliHelp(testMe, strLen, testLen, index + 1);
}

View file

@ -0,0 +1,3 @@
public static boolean pali(String testMe){
return testMe.matches("|(?:(.)(?<=(?=^.*?(\\1\\2?)$).*))+(?<=(?=^\\2$).*)");
}