public class Solution {
public boolean isPalindrome(String s) {
if(s==null)
return false;
s=s.toLowerCase();
for(int i =0,j=s.length()-1;i<=j;i++,j--){
while(!isAlpha(s.charAt(i))&&!isNum(s.charAt(i))){
i++;
if(i>j)
break;
} while(!isAlpha(s.charAt(j))&&!isNum(s.charAt(j))){
j--;
if(i>j)
break;
} if(i<=j){
if(s.charAt(i)!=s.charAt(j)){
return false;
}
} }
return true;
}
public boolean isAlpha(char a){
if((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z')){
return true;
}else{
return false;
}
} public boolean isNum(char a){
if(a >= '0' && a <= '9'){
return true;
}else{
return false;
}
}
}

125 Valid Palindrome的更多相关文章

  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 ...

  10. 125. Valid Palindrome (Array; Two-Pointers)

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

随机推荐

  1. java三大框架之一hibernate使用入门

    综述:Hibernate的作用就是让实体类与数据库映射,使数据持久化,用于替代JDBC,使我们不致于写那么多sql语句代码. 1. 首先在官网www.hibernate.org下载hibernate包 ...

  2. FORM触发器执行顺序

    触发器执行顺序: 1. 当打开FORM时: (1) PRE-FORM (2) PRE-BLOCK(BLOCK级) (3) WHEN-NEW-FORM-INSTANCE (4) WHEN-NEW-BLO ...

  3. C++ 类里面,函数占用存储空间问题

    转载自:http://blog.163.com/xping_lsr/blog/static/19654034520119804131721/ 先看两段代码: 代码段1:class A{public:i ...

  4. MySQL把多个字段合并成一条记录的方法

    转:http://www.111cn.net/database/mysql/71591.htm MySQL把多个字段合并成一条记录的方法 在mysql中字段合并可以使用很多函数来实现,如可以利用 GR ...

  5. {matlab}取二值图像centroid几种方法性能比较

    试验很简单,取二值图像的质心,三种方法做比较 1.完全采用矩阵性能不做任何循环操作,对find后的值进行除法与取余操作,从而得到centroid 2.完全采用循环操作,最简单明了 3.结合1,2,对每 ...

  6. Brn系列网上商城数据库说明文档

    单店版BrnShop_1.9.351数据字典:点击下载 多店版BrnMall_1.9.496数据字典:点击下载 有对网上商城程序设计感兴趣的朋友,欢迎加入QQ群:235274151,大家可以交流下!

  7. R语言学习笔记-变量的作用域

    R语言是如何将变量值和变量绑定的 在r语言中,当前的 workspace就是global enviroment,当输入变量名时,首先会在global enviroment中搜索该变量,如有,则将它显示 ...

  8. (十二) 一起学 Unix 环境高级编程 (APUE) 之 进程间通信(IPC)

    . . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...

  9. 如何在其他电脑上运行VS2005编译的DEBUG版应用程序

    做项目的过程中,遇到这样的问题:在自己的电脑上用VS2005编译好的DEBUG版程序在其它的没有安装VS2005的电脑上没有办法运行,郁闷至极啊. 直 接拷贝文件后,错误信息如下:"This ...

  10. 安全关闭多Activity的Application

    1.发送广播给每一个打开的Activity. 2.采用startActivityForResult()方法递归关闭. 3.使用EventBus框架的监听者模式,关闭时触发监听事件.