My C answer. Easy to Understand


  • 0
    S

    class Solution {

    public:

    bool isPalindrome(string s) {
        int n=0;
        n=s.size();
        if (s==""){
            return true;
        }
        int begin=0;
        int end=s.size()-1;
        while(begin<end){
              while (begin <end && !(isalnum(s[begin]))){
                  begin++;
              }
              while ( end >begin && !(isalnum(s[end]))){
                  end--;
              }
              if (isalnum(s[begin]) && (tolower(s[begin])!=tolower(s[end]))){
                  return false;
              }
              begin++;
              end--;
             
          }
        return true;
    }
    

    };


Log in to reply
 

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