leetcode- Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
“A man, a plan, a canal: Panama” is a palindrome.
“race a car” is not a palindrome.
bool isPalindrome(char* s) { //s=strupr(s); int i=0,j=strlen(s)-1,k=j+1; while(i<j){ while((!((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z')||(s[i]>='0'&&s[i]<='9'))) &&i<k){ i++; } while((!((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z')||(s[j]>='0'&&s[j]<='9'))) &&j>0){ j--; } //printf("%d%d,%d,%d",i,j,abs(s[i]-s[j]),'a'-'A'); if( i<=j&& (s[i]!=s[j] )&& !( ((s[j]>='A'&& s[j]<='Z') || (s[j]>='a' && s[j]<='z'))&& ((s[i]>='A'&& s[i]<='Z') || (s[i]>='a' && s[i]<='z'))&& (abs(s[i]-s[j])==('a'-'A'))) ) return false; i++;j--; } return true; }