目錄
一、題目
二、代碼
一、題目
125. 驗(yàn)證回文串 - 力扣(LeetCode)文章來源:http://www.zghlxwxcb.cn/news/detail-622978.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-622978.html
二、代碼
class Solution {
public:
bool ABC(char& s)
{
if (s >= 65 && s <= 90)
{
s += 32;
return true;
}
if (s >= 97 && s <= 122)
{
return true;
}
if (s >= '0' && s <= '9')
return true;
return false;
}
bool isPalindrome(string s) {
int start = 0;
int end = s.size() - 1;
while (start < end)
{
if (ABC(s[start]) && ABC(s[end]))
{
if (s[start] != s[end])
return false;
else
{
start++;
end--;
continue;
}
}
if (!ABC(s[start]) && !ABC(s[end]))
{
start++;
end--;
continue;
}
else if (ABC(s[start]))
{
end--;
}
else if (ABC(s[end]))
{
start++;
}
}
return true;
}
};
到了這里,關(guān)于125.驗(yàn)證回文串的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!