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) {
if(s.empty()) return true;
int sLength = s.length();
int front = -;
int rear = sLength;
char cFront;
char cRear;
while ()
{
cFront = s[++front];
cRear = s[--rear];
if(front > rear) break;
if(cFront <= 'Z'&& cFront >='A')
{
cFront +=;
}
if(cRear <= 'Z'&& cRear >='A')
{
cRear +=;
}
while( cFront < '' || (cFront < 'a' && cFront > '')|| cFront>'z')
{
cFront = s[++front];
if(front >= rear) break;
if(cFront <= 'Z'&& cFront >='A')
{
cFront +=;
}
}
while( cRear < '' || (cRear < 'a' && cRear > '')|| cRear>'z')
{
cRear = s[--rear];
if(front >= rear) break;
if(cRear <= 'Z'&& cRear >='A')
{
cRear +=;
}
}
if(front >= rear) break;
if(cFront!=cRear)
{
return false;
}
}
return true;
}
};

125. Valid Palindrome (Array; Two-Pointers)的更多相关文章

  1. 125. Valid Palindrome【easy】

    125. Valid Palindrome[easy] Given a string, determine if it is a palindrome, considering only alphan ...

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

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

  3. leetcode 125. Valid Palindrome ----- java

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

  4. LeetCode 125. Valid Palindrome

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

  5. Java [Leetcode 125]Valid Palindrome

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

  6. 【LeetCode】125. Valid Palindrome

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

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

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

  8. [leetcode]125. Valid Palindrome判断回文串

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

  9. LeetCode 125 Valid Palindrome(有效回文)(*)

    翻译 给定一个字符串.确定它是否是回文的,仅仅考虑当中的数字和字符并忽略其它. 比如. "A man, a plan, a canal: Panama" 是回文的. "r ...

随机推荐

  1. 关于MySQL 通用查询日志和慢查询日志分析

    MySQL中的日志包括:错误日志.二进制日志.通用查询日志.慢查询日志等等.这里主要介绍下比较常用的两个功能:通用查询日志和慢查询日志. 1)通用查询日志:记录建立的客户端连接和执行的语句. 2)慢查 ...

  2. gradle 配置java 项目maven 依赖

     1. 内置的 repositories { mavenCentral() } 2. maven 私服 repositories { maven { url "http://maven.al ...

  3. php mysql 字符集(三) (转)

    http://bbs.csdn.net/topics/390097514 gbk页面插入数据到utf8表,然后取出到gbk页面 首先, 这个set names x等价于SET character_se ...

  4. CentOS yum源设定使用方法的整理(转)

    CentOS yum更新了很多版本更新,我本人认为CentOS yum很好使的文件系统,在此向大家推荐CentOS应该是做为服务器的linux的佼佼者.CentOS采用的二进制包是rpm,不过包的依赖 ...

  5. pycaffe + anaconda2 + python2.7.配置

    1.首先要把caffe-windows用VS2013编译好(这一步很多门道,很麻烦很多坑),编辑props文件,使python支持选项开启,单独编译pycaffe项目就可以 2.将生成的在build/ ...

  6. 微软Azure平台 cloud service动态申请证书并绑定证书碰到的坑

    我们有一个saas平台 部分在azure的cloud service 使用lets encrypt来申请证书.每一个商家申请域名之后就需要通过Lets encrypt来得到证书并绑定证书. 主要碰到的 ...

  7. OpenCV在debug和release模式下选择不同的lib静态库文件

    这两天测试OpenCV显示到MFC的Picture控件上,终于测试成功了,但是换到release模式下就会imread失败.发现问题是导入的lib问题. 因为VS如果通过Property Manage ...

  8. Firewalld中的whitelist并不是规则白名单

    原文地址:http://www.excelib.com/article/292/show whitelist的含义 白名单跟防火墙结合在一起大家很容易将其理解为规则白名单,不过在Firewalld中w ...

  9. databaseDesgin-temple

    ylbtech-dbs:ylbtech-storebook- A, 返回顶部 1, 2, B,返回顶部 1, 2, C,返回顶部 作者:ylbtech出处:http://storebook.cnblo ...

  10. 杂项:HTML5-2/3-新元素

    ylbtech-杂项:HTML5-2/3-新元素 自1999年以后HTML 4.01 已经改变了很多,今天,在HTML 4.01中的几个已经被废弃,这些元素在HTML5中已经被删除或重新定义. 为了更 ...