其他分享
首页 > 其他分享> > 125 plindrome

125 plindrome

作者:互联网

 

 

1. boolean 

2. Character.isLetterOrDigit

3. two pointers 

4. i<=j. 

5. Character.toUpperCase(s.charAt(i));

 

 

 

public boolean isPalindrome(String s) {
if(s.isEmpty()) return true;
int i=0,j=s.length()-1;
while(i<=j){
while(i<=j&&!Character.isLetterOrDigit(s.charAt(i))){
i++;
}
while(i<=j &&!Character.isLetterOrDigit(s.charAt(j))){
j--;
}
if(i<=j && Character.toUpperCase(s.charAt(i))!=Character.toUpperCase(s.charAt(j))){
i++;
j--;
}
}
return true;

}
}

标签:return,++,Character,--,while,boolean,125,plindrome
来源: https://www.cnblogs.com/LLflag1/p/16504241.html