lintcode-有效回文字符串
来源:互联网 发布:java期末考试题库 编辑:程序博客网 时间:2024/05/18 02:27
给定一个字符串,判断其是否为一个回文串。只包含字母和数字,忽略大小写
例如 "A man, a plan, a canal: Panama"
是一个回文。
"race a car"
不是一个回文。
class Solution {public: bool check(char ch){ if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9')) return false; return true; } bool isPalindrome(string& s) { if(s.empty()) return true; if(s.size()==1) return true; int size=s.size(); int end=size-1; int begin=0; while(begin<end){ while(end>=0&&check(s[end])){ --end; } while(begin<size&&check(s[begin])){ ++begin; } if(tolower(s[end])!=tolower(s[begin])) return false; else --end,++begin; } return true; }};
0 0
- lintcode-有效回文字符串
- LintCode : 有效回文串
- LintCode-有效回文串
- lintcode --有效回文串
- 有效回文串,lintcode
- lintcode:有效回文串
- 有效回文串-LintCode
- lintcode 415有效回文串(Java)
- [LintCode 200] 最长回文字符串(Python)
- LintCode算法题解——岛屿个数、有效回文串、最长上升子序列
- leetcode 判断有效字符串是回文串Valid Palindrome
- LintCode:有效数字
- lintcode,有效数字
- lintcode 有效数字
- 有效数字-LintCode
- LintCode刷题:有效数字
- lintcode刷题--回文串
- LintCode- 分割回文串
- struct与union字节对齐问题
- 为Xcode6添加Empty Application选项
- 黑马程序员—反射机制
- Android studio中JNI-NDK开发打印LOG出现 undefined reference to `__android_log_print' 解决
- leetcode 9: Palindrome Number
- lintcode-有效回文字符串
- NSAttributedString几个用法
- 中断,异常,硬件断点
- [转]谈谈我对攻读计算机研究生的看法
- android__实践(短信发送器)
- ubuntu apt-get update 更新源失败的解决办法
- HDU-2066 一个人的旅行
- 最长重复子串与最长重复子序列
- Container With Most Water —— Leetcode