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.

Solution 1:

class Solution
{
public:
bool isPalindrome(string s)
{
int left = , right = s.length() - ;
while(left < right)
{
char a = tolower(s[left]), b = tolower(s[right]);
if(!isalnum(a))
{
++left;
continue;
}
if(!isalnum(b))
{
--right;
continue;
}
if(a != b) return false; ++left;
--right;
}
return true; }
};

Valid Palindrome ---- LeetCode 125的更多相关文章

  1. Valid Palindrome [LeetCode]

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  2. Valid Palindrome leetcode java

    题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...

  3. [LeetCode]题解(python):125 Valid Palindrome

    题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...

  4. 【一天一道LeetCode】#125. Valid Palindrome

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  5. LeetCode(125)题解--Valid Palindrome

    https://leetcode.com/problems/valid-palindrome/ 题目: Given a string, determine if it is a palindrome, ...

  6. [LeetCode] 125. Valid Palindrome 验证回文字符串

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  7. 【LeetCode】125. Valid Palindrome 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 列表生成式 正则表达式 双指针 日期 题目地址:https:/ ...

  8. leetcode 125. Valid Palindrome ----- java

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  9. LeetCode 125. Valid Palindrome

    这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...

随机推荐

  1. Migrating an ASP.NET MVC application to ADFS authentication

    I recently built an ASP.NET application at work to help track internal use of our products. It's bee ...

  2. cookie多次点赞效果

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  3. Jmeter性能测试入门(链接收藏)

    Jmeter性能测试入门: http://www.cnblogs.com/TankXiao/p/4045439.html

  4. 生活life

    1.想办法努力挣钱,而不是如何省钱. 2.再愤怒也不大吼大叫,保持冷静. 3.喜欢的东西自己努力赚钱买. 4.少说多做,能站不坐,适当运动. 5.不要认为找个有钱男人就什么都有了.世界上年轻的女孩子, ...

  5. 无废话SharePoint入门教程一[SharePoint概述]

    一.前言 听说SharePoint也有一段时间了,可一直处在门外.最近被调到SharePoint实施项目小组,就随着工作一起学习了一下实施与开发.但苦于网上SharePoint入门的东西实在太少,导致 ...

  6. CentOS6.5 下安装 texlive2015 并设置 ctex 中文套装

    0 卸载旧版本的 texlive 0.1 卸载 texlive2007 如果系统没有安装过texlive,则跳过第0步. 可以在终端中使用如下命令查询本机已经安装的tex和latex版本: [She@ ...

  7. 苹果公布WWDC2016时间 并做了个程序员情怀网页

    新浪手机讯 4月19日上午消息,苹果公司今日正式确定2016年全球开发者大会(WWDC)开幕时间:6月13-17日,并做了个非常有意思的代码风格页面. 网友戏称这个页面只有程序员们才能看懂,它的首页是 ...

  8. Visual Basic 2012 借助DataGridView控件将SQL server2012 数据导入到Excel 2010

    摘  要: SQL Server 2012 数据和Excel 2010之间的连接和数据的传输,本篇文章主要针对的是SQL Server 2012 数据导入到Excel 2010文件中.Excel软件对 ...

  9. java.io.FileNotFoundException: ...\ibs\library-1.0.17.jar (系统找不到指定的文件。)

    网上找一下相应的jar包,放到对应的路径下就好了

  10. web学习之servlet

    1)web服务软件作用: 把本地资源共享给外部访问 2)tomcat服务器基本操作 : 启动:  %tomcat%/bin/startup.bat 关闭: %tomcat%/bin/shutdown. ...