leetcode - Valid Palindrome
来源:互联网 发布:linux 网络学习 编辑:程序博客网 时间:2024/06/09 21:03
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,"A man, a plan, a canal: Panama"
is a palindrome."race a car"
is not a palindrome.
Note:
Have you consider that the string might be empty? This is a good question to ask during an interview.
For the purpose of this problem, we define empty string as valid palindrome.
class Solution {public: bool isPalindrome(std::string s) { std::string _s; for (int i = 0; i < s.size(); ++i) { if(('a' <= s[i] && s[i] <= 'z') || ('A' <= s[i] && s[i] <= 'Z') || ('0' <= s[i] && s[i] <= '9')) { if('A' <= s[i] && s[i] <= 'Z') s[i] += 32; _s.push_back(s[i]); } } std::string t(_s); reverse(_s.begin(), _s.end()); if(t == _s) return true; else return false; }};
0 0
- [Leetcode] Valid Palindrome
- Leetcode: Valid Palindrome
- leetcode 55: Valid Palindrome
- [LeetCode] Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode - Valid Palindrome
- [leetcode]Valid Palindrome
- [LeetCode]Valid Palindrome
- [Leetcode]Valid Palindrome
- LeetCode-Valid Palindrome
- [leetcode] Valid Palindrome
- LeetCode 125: Valid Palindrome
- LeetCode - Valid Palindrome
- leetcode之Valid Palindrome
- LeetCode | Valid Palindrome
- [leetcode]Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode题解:Valid Palindrome
- 80x86汇编小站-公告
- 黑客小帅收徒QQ2206686874
- 百钱百鸡问题
- Autolayout及VFL经验分享
- 用CImage加载内存里的Image
- leetcode - Valid Palindrome
- 73 对策字符串的最大长度 回文串的判断
- 黑马程序员_iOS开发之OC之面向对象之思想、类和对象
- 常用第三方框架。。AndBase
- 转载 SQL group by语句
- day53,page70
- LeetCode::Permutations
- 74 数组中超过出现次数超过一半的数字
- iptables实现路由转发