---
# System prepended metadata

title: 0125. Valid Palindrome
tags: [Leetcode, FaceBook, Easy, Palindrome]

---

# 0125. Valid Palindrome
###### tags: `Leetcode` `Easy` `FaceBook` `Palindrome`
Link: https://leetcode.com/problems/valid-palindrome/
## 注意语法~
string upperCase to lowerCase
```s.toUpperCase; s.toLowerCase;```
判断是否是标点
``` !Character.isLetterOrDigit(c)```
Character upperCase to lowerCase
```Character.toLowerCase(c)```
## Code
```java=
class Solution {
    public boolean isPalindrome(String s) {
        char[] charArray = s.toCharArray();
        int start = 0;
        int end = s.length()-1;
        while(start<end){
            if(Character.isLetterOrDigit(charArray[start])&&Character.isLetterOrDigit(charArray[end])){
                if(Character.toLowerCase(charArray[start])==Character.toLowerCase(charArray[end])){
                    start++;
                    end--;
                }
                else{
                    return false;
                }
            }
            if(!Character.isLetterOrDigit(charArray[start]))start++;
            if(!Character.isLetterOrDigit(charArray[end]))end--;
        }
        return true;
    }
}
```