[leetcode]Valid Palindrome
来源:互联网 发布:淘宝上很便宜的化妆品 编辑:程序博客网 时间:2024/05/17 02:07
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(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int p=0, q=s.size()-1; while(p<q){ if(!((s[p] >= 'a' && s[p] <= 'z') || (s[p] >= 'A' && s[p] <= 'Z') ||(s[p] - '0' >= 0 && s[p] -'0'<=9))) { p++; continue; } if(!((s[q] >= 'a' && s[q] <= 'z') || (s[q] >= 'A' && s[q] <= 'Z') ||(s[q] - '0' >= 0 && s[q] -'0'<=9))) { q--; continue; } if(s[p]!=s[q] && s[p]-s[q] != 'A'-'a' && s[p]-s[q] != 'a'-'A') return false; p++; q--; } return true; }};
- [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
- 书籍
- OSG内存管理
- HDU 1319.素数剪切(筛选法)
- UVaOJ165 - Stamps
- unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法
- [leetcode]Valid Palindrome
- JAVA中的interface和ios中的对比
- UVaOJ167 - The Sultan's Successors
- UVaOJ140 - Bandwidth
- android 4.0 WIFI 初始化过程(应用层+框架层)
- 《Javascript权威指南》学习笔记之~Chapter 3. Type, Values, and Variables
- [MFC]线程的挂起与恢复
- 20部商战电影,电影中的商学院
- UVaOJ10603 - Fill