Last active
July 27, 2019 13:32
-
-
Save Jun711/6b737bf7165680cf0d17ca9c20820043 to your computer and use it in GitHub Desktop.
TestDome - Palindarome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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