https://leetcode.com/problems/valid-palindrome/

题目:

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.

思路:

easy.

AC代码:

 class Solution {
public:
bool isPalindrome(string s) {
int a=,b=s.size()-;
while(a<b){
if(!((s[a]>='a'&&s[a]<='z')||(s[a]>='A'&&s[a]<='Z')||(s[a]>=''&&s[a]<=''))){
a++;
continue;
}
if(!((s[b]>='a'&&s[b]<='z')||(s[b]>='A'&&s[b]<='Z')||(s[b]>=''&&s[b]<=''))){
b--;
continue;
}
if((s[a]>='a'&&s[a]<='z')){
if((s[a]!=s[b])&&(s[a]+'A'-'a'!=s[b])){
return false;
}
}
else if((s[a]>='A'&&s[a]<='Z')){
if((s[a]!=s[b])&&(s[a]!=s[b]+'A'-'a')){
return false;
}
}
else{
if(s[a]!=s[b]){
return false;
}
}
a++;
b--;
}
return true;
}
};

LeetCode(125)题解--Valid Palindrome的更多相关文章

  1. [LeetCode 题解]: Valid Palindrome

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

  2. LeetCode(125) Valid Palindrome

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

  3. 【LeetCode OJ】Valid Palindrome

    Problem Link: http://oj.leetcode.com/problems/valid-palindrome/ The following two conditions would s ...

  4. 【LeetCode练习题】Valid Palindrome

    Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...

  5. LeetCode OJ:Valid Palindrome(验证回文)

    Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...

  6. LeetCode算法题-Valid Palindrome(Java实现)

    这是悦乐书的第174次更新,第176篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第33题(顺位题号是125).给定一个字符串,确定它是否是回文,只考虑字母数字字符并忽略 ...

  7. 【LeetCode】680. Valid Palindrome II

    Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...

  8. 【LeetCode】680. Valid Palindrome II 验证回文字符串 Ⅱ(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 思路来源 初版方案 进阶方案 日期 题目地址 ...

  9. LeetCode算法题-Valid Palindrome II(Java实现)

    这是悦乐书的第287次更新,第304篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第155题(顺位题号是680).给定非空字符串s,最多可以删除一个字符. 判断它是否是回 ...

随机推荐

  1. MGW——美团点评高性能四层负载均衡

    转自美团点评技术博客:https://tech.meituan.com/MGW.html 前言 在高速发展的移动互联网时代,负载均衡有着举足轻重的地位,它是应用流量的入口,对应用的可靠性和性能起着决定 ...

  2. C#中DataTable中Rows.Add 和 ImportRow 对比

    最近参加项目中,数据操作基本都是用DataTable的操作,老代码中有些地方用到DataTable.Rows.Add又有些代码用的DataTable.ImportRow,于是就对比了一下 VS查询说明 ...

  3. 【CF20C】Dijkstra?(DIJKSTRA+HEAP)

    没什么可以说的 做dijk+heap模板吧 以后考试时候看情况选择SFPA和DIJKSTRA ; ..]of longint; dis:..]of int64; a:..]of int64; b:.. ...

  4. linux 下高精度时间

    今天在公司代码中看到了使用select函数的超时功能作定时器的用法,便整理了如下几个Linux下的微秒级别的定时器.在我的Ubutu10.10 双核环境中,编译通过. /* * @FileName:  ...

  5. kafka性能调优

    https://blog.csdn.net/u013063153/article/details/73826322

  6. Python内置函数和匿名函数

    内容回顾: 1.列表推导式 [变量(加工后的变量) for 变量 in iterable] 循环模式 [变量(加工后的变量) for 变量 in iterable if 条件] 筛选模式 生成器表达式 ...

  7. nrm+nvm

    一.nvm的安装和使用   nvm全称Node Version Manager是 Nodejs 版本管理器,它让我们能方便的对 Nodejs 的版 本进行切换. nvm 的官方版本只支持 Linux ...

  8. Java面向对象--static关键字

  9. 使用一个数组存储一个英文句子"java is an object oriented programing language"

    class fun { public static void main(String[] args) { String str="java is an object oriented pro ...

  10. [simple-orm-mybaits]基于Mybatis的ORM封装介绍

    目录 前言 ORM框架现状 Mybatis优缺点 simple-orm-mybatis设计思路介绍 simple-orm-mybatis使用说明 simple-orm-mybatis实际使用 推荐最佳 ...