C# Straight Forward Solution


  • 0
    H

    ublic class Solution {

    public bool IsPalindrome(string s) {
        int i = 0;
        int j = s.Length-1;
        
        while( i < j ){
            if(!Char.IsLetterOrDigit(s[i])){
                i++;
            }
            else if(!Char.IsLetterOrDigit(s[j])){
                j--;
            }
            else if( Char.ToLower(s[i]) != Char.ToLower(s[j]) ){ 
                return false;
            }
            else{
                i++;
                j--;
            }
            
        }
        
        return true;
    }
    

    }


Log in to reply
 

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