A.b,. Case is failing : Cannot figure it


  • 0
    E
    class Solution {
    public:
        bool isPalindrome(string s) {
            
            transform(s.begin(), s.end(), s.begin(), ::tolower);
       auto i = s.begin();
          auto j = s.end()-1;
    
          cout<<*i<<endl;
          cout<<*j<<endl;
    
    
          if(s.length()==1) return true;
    
          while((i<=j) && ((isdigit(*i)) || isalpha(*j)) && ((isdigit(*i)) || isalpha(*j) ))
          {
              if(!isdigit(*i) && !(isalpha(*i))) { i++  ; continue; }
    
              if(!isdigit(*j) && !isalpha(*j)) { j--; continue;}
    
              if(*i==*j)
                {
                  cout<<*i<<endl;
                  i++;
                  j--;
                  continue;
                }
              else
                return false;
    
          }
    
          return true;
      }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.