# 125.Valid Palindrome

**125.Valid Palindrome**

> 给定一个字符串，验证它是否是回文串，只考虑字母和数字字符，可以忽略字母的大小写。 说明：本题中，我们将空字符串定义为有效的回文串。

```
示例 1:

输入: "A man, a plan, a canal: Panama"
输出: true
示例 2:

输入: "race a car"
输出: false
```

难度：Easy 方法:去除无关字符，大小写转换之后，再判断即可。 代码如下:

```
class Solution {
public:
    bool isPalindrome(string s) {
        int t=s.length();
        string tmp;
        for(int i=0;i<t;i++)
        {
            if(s[i]>64 && s[i]<91)
                tmp+=s[i]+32;
            else if(s[i]>96 && s[i]<123)
                tmp +=s[i];
            else if(s[i]>47 &&s[i]<58)
                tmp +=s[i];
        }
       // cout << tmp << endl;
        int n=tmp.length();
        for(int i=0;i<n/2;i++)
        {
            if(tmp[i]!=tmp[n-i-1]) return false;
        }
        return true;
    }
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dfine.gitbook.io/leetcode/125.valid_palindrome.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
