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. 怎样创建Linux Initrd

    Linux初始RAM磁盘(initrd)是在系统引导过程中挂载的一个暂时根文件系统,用来支持两阶段的引导过程.initrd文件里包括了各种可运行程序和驱动程序.它们能够用来挂载实际的根文件系统,然后再 ...

  2. smarty缓存的使用

    <?php require './smarty/Smarty.class.php'; $sm = new Smarty; //$sm->force_compile = true; $sm- ...

  3. RabbitMQ概念

    RabbitMQ 即一个消息队列,_主要是用来实现应用程序的异步和解耦,同时也能起到消息缓冲,消息分发的作用._RabbitMQ使用的是AMQP协议,它是一种二进制协议.默认启动端口 5672. 在 ...

  4. XaaS简介(关于IssS,PaaS以及SaaS)

    IaaS,比较容易理解,提供了一个操作系统以及操作系统的硬件支撑:阿里云: PaaS,提供了一个平台,或者说,使用PaaS是希望能够在上面建立自己的服务/应用,同时平台会提供一些API或者工具,能够降 ...

  5. Oracle修改主键约束

    项目需求,有张表,原有三个联合主键,现在需要再加一个字段进去,而恰恰这个字段可以为空的.去数据库捞了一把,还好数据都不为空: SQL> select count(*) from t_wlf_re ...

  6. jQuery实现页面监听(某一个值发生改变时触发)

    使用jQuery实现页面中监听   页面中某一个值(如input输入框)发生改变时触发. <html> <head> <title>RunJS</title& ...

  7. Mybatis数据的增删改查

    数据: Student{id int,name String ,age int} 配置mybatis-config.xml <?xml version="1.0" encod ...

  8. (转)Inno Setup入门(十四)——替换安装程序和卸载程序的图标

    本文转载自:http://blog.csdn.net/yushanddddfenghailin/article/details/17250937 通常Inno生成的安装文件的图标是一个光盘和显示器,如 ...

  9. wkhtmltopdf Windows下 测试demo 成功

    html2pdf 转pdf 中文不换行 然后找到了wkhtmltopdf 支持中文换行 样式也支持 在PHP中生成PDF文件,可以使用 FPDF 和 TCPDF .但是它们只能用于创建简单的表格,当涉 ...

  10. pubmed检索完全攻略

    第一章 进入PubMed魔法学校--PubMed 概述 有位退休的老教授不止一次的向我感叹:"你们现在真是幸福,我们那时候要查一篇相关的文献,要到图书馆一本一本目录去检索.尤其是做一些别人不 ...