> For the complete documentation index, see [llms.txt](https://r24zeng.gitbook.io/leetcode-notebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://r24zeng.gitbook.io/leetcode-notebook/bu-chong-2140-dao/125.-valid-palindrome.md).

# 125. Valid Palindrome

\# Easy

{% hint style="info" %}
Only when `s[i]` and `s[j]` are alphanumeric, then start to compare.
{% endhint %}

```python
class Solution:
    def isPalindrome(self, s: str) -> bool:
        # edge case
        if len(s) == 0 or len(s) == 1:
            return True
        
        i = 0
        j = len(s)-1
        while i < j:
            if self.isAlp(s[i]) == False:
                i += 1
            elif self.isAlp(s[j]) == False:
                j -= 1
            else:
                if s[i].lower() != s[j].lower():
                    return False
                else:
                    i += 1
                    j -= 1
            
        return True
    
    def isAlp(self, ch):
        if ch >= 'a' and ch <= 'z':
            return True
        if ch >= 'A' and ch <= 'Z':
            return True
        if ch >= '0' and ch <= '9':
            return True
        return False
```

{% hint style="success" %}
string.lower() in Python, convert Capital letter to lower cases.
{% endhint %}
