Skip to content

Instantly share code, notes, and snippets.

@Jun711
Last active July 27, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jun711/6b737bf7165680cf0d17ca9c20820043 to your computer and use it in GitHub Desktop.
Save Jun711/6b737bf7165680cf0d17ca9c20820043 to your computer and use it in GitHub Desktop.
TestDome - Palindarome
public class Palindrome {
public static boolean isPalindrome(String word) {
if (word.length() <= 1)
return true;
char[] wordArr = word.toLowerCase().toCharArray();
int end = wordArr.length - 1;
int mid = wordArr.length / 2;
for (int i = 0; i < mid; i++) {
if (wordArr[i] != wordArr[end - i])
return false;
}
return true;
}
public static void main(String[] args) {
System.out.println(Palindrome.isPalindrome("Deleveled"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment