125. Valid Palindrome

这个题不怎么容易。。

正常做两头只找大小写和数字。

用rex简单很多。。

public class Solution {
    public boolean isPalindrome(String s) {
        int l = 0;
        
        s = s.trim().toLowerCase().replaceAll("[^a-z0-9]","");
        int r = s.length()-1;
        while (l < r) {
            if (s.charAt(l++) != s.charAt(r--)) return false;
        }
        return true;
    }
}
posted @ 2016-11-14 03:50  哇呀呀..生气啦~  阅读(80)  评论(0编辑  收藏  举报