Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- bool isPalindrome(string s) {
- int n = (int)s.size();
- int i=0, j=n-1;
- while( i < j )
- {
- while( i< j && !isalnum(s[i]))i++;
- while( i < j && !isalnum(s[j]))j--;
- if(tolower(s[i]) !=tolower(s[j])) return false;
- i++;
- j--;
- }
- return true;
- }
- };
Add Comment
Please, Sign In to add comment