125 Valid Palindrome
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的更多相关文章
- 125. Valid Palindrome【easy】
125. Valid Palindrome[easy] Given a string, determine if it is a palindrome, considering only alphan ...
- [LeetCode]题解(python):125 Valid Palindrome
题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...
- leetcode 125. Valid Palindrome ----- java
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode 125. Valid Palindrome
这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...
- Java [Leetcode 125]Valid Palindrome
题目描述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- 【LeetCode】125. Valid Palindrome
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- 【一天一道LeetCode】#125. Valid Palindrome
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- [leetcode]125. Valid Palindrome判断回文串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode 125 Valid Palindrome(有效回文)(*)
翻译 给定一个字符串.确定它是否是回文的,仅仅考虑当中的数字和字符并忽略其它. 比如. "A man, a plan, a canal: Panama" 是回文的. "r ...
- 125. Valid Palindrome (Array; Two-Pointers)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
随机推荐
- mysql与oracle的存储过程有什么区别?
MySQL存储过程 (1). 格式 MySQL存储过程创建的格式:CREATE PROCEDURE过程名 ([过程参数[,...]]) [特性 ...]过程体 案例分析: 参数 MySQL存储过程的参 ...
- Eclipse 和 HSQLDB: 将关系数据库服务器嵌入到 Eclipse 中,第 2 部分
HSQLDB 开发者角色 对 HSQLDB 与 Eclipse 工作台的集成感兴趣的开发者可以很容易地被分为两类: 客户机开发者,他们只是用 HSQLDB 来存储数据. 引擎开发者,他们通过添加新的标 ...
- SqlDataReader的使用
1.建立数据库连接: 2.设置数据库指令: 3.数据拾取器接收输出的数据: 4.遍历打印数据: using System; using System.Collections.Generic; usin ...
- 对Web标准的理解。可用性和可访问性
一Web标准 简单的说,就是HTML.CSS.JavaScript这三者分离.WEB标准不是某一个标准,而是一系列标准的集合.网页主要由三部分组成:结构(Structure).表现(Presentat ...
- 项目支持Servlet3.0的新特性
一.Servlet3.0介绍 Servlet3.0是Java EE6规范的一部分,Servlet3.0提供了注解(annotation),使得不再需要在web.xml文件中进行Servlet的部署描述 ...
- [华清远见]FPGA公益培训
本套视频教程为华清远见 网络公益培训活动,主讲人:姚远老师,华清远见高级讲师. ------------------------------------------------------------ ...
- VC++中操作XML(MFC、SDK)转
[转]VC++中操作XML(MFC.SDK) XML在Win32程序方面应该没有在Web方面应用得多,很多Win32程序也只是用XML来存存配置信息而已,而且没有足够的好处的话还不如用ini.VC++ ...
- LoadRunner ---手动关联与预关联
手动关联 如果脚本很长,那么我们想找到一个脚本中哪些地方是需要关联的并不是一件容易的事情.这时,我们可以通过脚本对比的方法找 ...
- 在Hadoop-2.2.0集群上安装 Hive-0.13.1 with MySQL
fesh个人实践,欢迎经验交流!本文Blog地址:http://www.cnblogs.com/fesh/p/3872872.html 软件环境 操作系统:Ubuntu14.04 JDK版本:jdk1 ...
- SQL Server数据库表重置自增主键号(通常是指ID)
执行 DBCC CHECKIDENT ('table_name', NORESEED) 以确定列中的当前最大值 然后使用 DBCC CHECKIDENT ('table_name', RESEED,n ...