public boolean isPalindrome(String s) {
        boolean isPalindrome = true;
        s = s.toLowerCase();
        int begin = 0, end = s.length() - 1;
        while (begin < end) {
            char charBegin = s.charAt(begin), charEnd = s.charAt(end);
            if (!Character.isLetterOrDigit(charBegin)) {
                ++begin;
                continue;
            }
            if (!Character.isLetterOrDigit(charEnd)) {
                --end;
                continue;
            }
            if (charBegin != charEnd) {
                isPalindrome = false;
                break;
            }
            ++begin;
            --end;
        }
        return isPalindrome;
    }