@@ -0,0 +1,1721 @@
+package com.tuinsomniacorp.leetcode.easy;%0D%0A%0D%0A/**%0D%0A * %0D%0A * Given a string, determine if it is a palindrome, considering only%0D%0A * alphanumeric characters and ignoring cases.%0D%0A * %0D%0A * For example, %22A man, a plan, a canal: Panama%22 is a palindrome. %22race a car%22%0D%0A * is not a palindrome.%0D%0A * %0D%0A * Note: Have you consider that the string might be empty? This is a good%0D%0A * question to ask during an interview.%0D%0A * %0D%0A * For the purpose of this problem, we define empty string as valid palindrome.%0D%0A * %0D%0A * @author Angel Banuelos ing.angel.banuelos@gmail.com%0D%0A *%0D%0A */%0D%0Apublic class ValidPalindrome %7B%0D%0A%0D%0A%09public boolean isPalindrome(String s) %7B%0D%0A%09%09s = s.toUpperCase();%0D%0A%09%09int i = 0;%0D%0A%09%09int n = s.length() - 1;%0D%0A%09%09while (i %3C n) %7B%0D%0A%09%09%09char x = s.charAt(i);%0D%0A%09%09%09char y = s.charAt(n);%0D%0A%09%09%09// Letter Number%0D%0A%09%09%09if (!isCharacter(x) && !isNumeric(x)) %7B%0D%0A%09%09%09%09i++;%0D%0A%09%09%09%09continue;%0D%0A%09%09%09%7D else if (!isCharacter(y) && !isNumeric(y)) %7B%0D%0A%09%09%09%09n--;%0D%0A%09%09%09%09continue;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09if (x != y) %7B%0D%0A%09%09%09%09return false;%0D%0A%09%09%09%7D%0D%0A%09%09%09i++;%0D%0A%09%09%09n--;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%0D%0A%09public boolean isNumeric(char c) %7B%0D%0A%09%09if (c %3E= 48 && c %3C= 57) %7B%0D%0A%09%09%09return true;%0D%0A%09%09%7D%0D%0A%09%09return false;%0D%0A%09%7D%0D%0A%0D%0A%09public boolean isCharacter(char c) %7B%0D%0A%09%09if (c %3E= 65 && c %3C= 90) %7B%0D%0A%09%09%09return true;%0D%0A%09%09%7D%0D%0A%09%09return false;%0D%0A%09%7D%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%0D%0A%09%09String word = %22A man, a plan, a canal: Panama%22;%0D%0A%09%09String easy = %220P%22;%0D%0A%09%09String trick = %22%22;%0D%0A%0D%0A%09%09ValidPalindrome validPalindrome = new ValidPalindrome();%0D%0A%09%09System.out.println(%22is a palindtrome: %22 + validPalindrome.isPalindrome(easy));%0D%0A%09%09System.out.println(%22is a palindtrome: %22 + validPalindrome.isPalindrome(word));%0D%0A%09%09System.out.println(%22is a palindtrome: %22 + validPalindrome.isPalindrome(trick));%0D%0A%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

leetcode Valid Palindrome