knakul853

Untitled

Jun 20th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. /**
  2. knakul853
  3. **/
  4.  
  5. class Solution {
  6. public:
  7.     bool isPalindrome(string s) {
  8.        
  9.        int n = (int)s.size();
  10.         int i=0, j=n-1;
  11.        
  12.         while( i < j )
  13.         {
  14.             while( i< j && !isalnum(s[i]))i++;
  15.             while( i < j && !isalnum(s[j]))j--;
  16.            
  17.             if(tolower(s[i]) !=tolower(s[j])) return false;
  18.             i++;
  19.             j--;
  20.            
  21.         }
  22.        
  23.        
  24.         return true;
  25.     }
  26. };
Add Comment
Please, Sign In to add comment