C# Solution - Accepted


  • 0
    S
      public bool IsPalindrome(string s)
        {        
            if(s.Length <=1)
                return true;
    
            string str = s.ToLower();         
            int start = 0;
            int end = str.Length -1;
    
            while(start <= end )
            {
                if (!(str[start] >= 97 && str[start] <= 122) && !(str[start] >= 48 && str[start] <= 57))
                {
                    start++;
                    continue;
                }
                if (!(str[end] >= 97 && str[end] <= 122) && !(str[end] >= 48 && str[end] <= 57))
                {
                    end--;
                    continue;
                }
    
                if (str[start] != str[end])
                    return false;
    
                start++;
                end--;
    	    }
    
    	    return true;
            
        }
    

Log in to reply
 

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