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  check(char test, char & c)
{
if(test >= 'a' && test <= 'z')
{
c = test;
return true;
}else if(test >= 'A' && test <= 'Z'){

c = test - 'A' + 'a';
return true;
}else if (test >= '' && test <= ''){

c = test;
return true;
}
return false;
}
bool isPalindrome(string s) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int j = s.length();
if(j-- == ) return true;
int i = ; char head,tail;
while(i<j){
while(i<j){
i++;
}
if(i>=j) return true;

while(i<j){
if(check(s[j], tail)) break;
j--;
}
if(i>=j) return true;
if(head != tail ) return false;
i++;j--;
}
return true ;
}
};

## LeetCode_Valid Palindrome的更多相关文章

1. 【leeetcode】125-Valid Palindrome

problem 125. Valid Palindrome 参考 1. Leetcode_Valid Palindrome; 完

2. PALIN - The Next Palindrome 对称的数

A positive integer is called a palindrome if its representation in the decimal system is the same wh ...

3. [LeetCode] Longest Palindrome 最长回文串

Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...

4. [LeetCode] Palindrome Pairs 回文对

Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...

5. [LeetCode] Palindrome Permutation II 回文全排列之二

Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

6. [LeetCode] Palindrome Permutation 回文全排列

Given a string, determine if a permutation of the string could form a palindrome. For example," ...

7. [LeetCode] Palindrome Linked List 回文链表

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time ...

8. [LeetCode] Shortest Palindrome 最短回文串

Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...

9. [LeetCode] Palindrome Partitioning II 拆分回文串之二

Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...

## 随机推荐

1. lintcode循环数组之连续子数组求和

v 题目:连续子数组求和 II 给定一个整数循环数组(头尾相接),请找出一个连续的子数组,使得该子数组的和最大.输出答案时,请分别返回第一个数字和最后一个数字的值.如果多个答案,请返回其中任意一个. ...

2. [Dynamic Language] 用Sphinx自动生成python代码注释文档

用Sphinx自动生成python代码注释文档 pip install -U sphinx 安装好了之后,对Python代码的文档,一般使用sphinx-apidoc来自动生成:查看帮助mac-abe ...

3. javac

http://openjdk.java.net/groups/compiler/ http://crazyjavahacking.org/tag/javac/ http://openjdk.java. ...

4. node.js 针对不同的请求路径(url) 做出不同的响应

5. linux下的shell和脚本

1.各种Unix shell linux下的shell基本是从unix环境中的shell发展而来,贴一下wiki:其中我们常用的,可归类为Bourne Shell(/usr/bin/sh或/bin/s ...

6. Android Studio的Terminal配置

7. MinerBean.java 数据库表 miner bean

MinerBean.java 数据库表 miner bean package com.iteye.injavawetrust.miner; import java.util.Date; /** * 数 ...

8. poi导出Excel直接在浏览器下载

需求:导出成Excel格式,要在浏览器看到类似于下载的效果. 导出的Excel和下载在同一个目录下. xxController.java // 导出 @RequestMapping(value = & ...

9. Loj #2321. 「清华集训 2017」无限之环

Loj #2321. 「清华集训 2017」无限之环 曾经有一款流行的游戏,叫做 *Infinity Loop***,先来简单的介绍一下这个游戏: 游戏在一个 $$n \times m$$ 的网格状棋 ...

10. Contest2156 - 2019-3-7 高一noip基础知识点 测试2 题解版

传送门 预计得分:100+70+100+50=320 实际得分100+63+77+30=270 Ctrl_C+Ctrl_V时不要粘贴翻译的,直接粘原文, In a single line of the ...