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 ...
随机推荐
- <meta http-equiv="refresh" content="0; url=">是什么意思?
页面定期刷新,如果加url的,则会重新定向到指定的网页,content后面跟的是时间(单位秒),把这句话加到指定网页的<head></head>里一般也用在实时性很强的应用中, ...
- CSS子元素居中(父元素宽高已知,子元素未知)
<style> .container{width:400px; height:400px; position:relative;} .center{position:absolute; l ...
- 5.Makefile的原理及应用
1.概念 目标:目标顶格写,后面是冒号(冒号后面是依赖) 依赖:依赖是用来产生目标的原材料. 命令:命令前面一定是两个Tab,不能是定格,也不能说多个空格.命令就是要生成那个目标需要做的动作. 2.基 ...
- 【EF学习笔记10】----------主从表级联操作
主从表 级联新增 Console.WriteLine("=========主从表 级联新增=========="); using (var db = new Entities()) ...
- Django过滤器列表
Django 模板过滤器也是我们在以后基于 Django 网站开发过程中会经常遇到的,如显示格式的转换.判断处理等.以下是 Django 过滤器列表,希望对为大家的开发带来一些方便. 一.形式:小写 ...
- postman-根据接口文档进行测试
根据接口文档来测试 1.get请求
- Delphi调用REST
Delphi调用REST很简单,首先在界面上放上: RESTClient1: TRESTClient; RESTRequest1: TRESTRequest; RESTResponse1: TREST ...
- tomcat7.0 处理问题
修改tomcat的用户密码 打开tomcat的conf/tomcat-users.xml 将<user username="admin" password="123 ...
- 三级联动---DropDownList控件
AutoPostBack属性:意思是自动回传,也就是说此控件值更改后是否和服务器进行交互比如Dropdownlist控件,若设置为True,则你更换下拉列表值时会刷新页面(如果是网页的话),设置为fl ...
- Object转bigdecimal
/*由数字字符串构造BigDecimal的方法 *设置BigDecimal的小数位数的方法 */ import java.math.BigDecimal; //数字字符串 String StrBd=& ...