Created
February 16, 2012 18:40
-
-
Save anpieber/1846944 to your computer and use it in GitHub Desktop.
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 static boolean isPalindrome(String pal) { | |
| String nPal = pal.toUpperCase(); | |
| String simplified = nPal.replaceAll("\\W", ""); | |
| System.out.println(simplified); | |
| char[] splitted = simplified.toCharArray(); | |
| for (int i = 0; i < simplified.length() / 2; i++) { | |
| if (splitted[i] != splitted[simplified.length() - 1 - i]) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment