LeetCode-Valid Palindrome
来源:互联网 发布:水利造价软件 编辑:程序博客网 时间:2024/04/29 05:49
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.
Solution:Code:
<span style="font-size:14px;">class Solution {public: bool isPalindrome(string s) { int begin = 0, end = s.size()-1; while (begin < end) { if ((isalpha(s[begin]) || isdigit(s[begin])) && (isalpha(s[end]) || isdigit(s[end]))) { if (tolower(s[begin]) != tolower(s[end])) return false; ++begin; --end; continue; } if (!isalpha(s[begin]) && !isdigit(s[begin])) ++begin; if (!isalpha(s[end]) && !isdigit(s[end])) --end; } return true; }};</span>
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
- 利用Oracle物化视图优化项目查询
- Java循环中标签的作用
- 虚拟目录是什么作用--如何配置IIS设置虚拟目录
- R语言加载rJava相关包出现错误的总结
- 用Windows Server 2008搭建时钟同步服务器
- LeetCode-Valid Palindrome
- 初识虚拟化技术
- VLC部分API学习
- 查看手机分辨率
- Hadoop存在巨大数据安全风险的理由
- Myeclipse 运行maven控制台中文乱码
- PHP基础 数据类型 运算符
- 精辟!(/usr/bin/ld: cannot find -lxxx)可能出现的问题和原因
- 短信模拟器