题目链接
思路
简单双指针应用
代码
class Solution {
public boolean isPalindrome(String s) {
StringBuffer sgood = new StringBuffer();
int length = s.length();
for(int i = 0; i < length; i++){
char ch = s.charAt(i);
if(Character.isLetterOrDigit(ch)){
sgood.append(Character.toLowerCase(ch));
}
}
StringBuffer sgood_rev = new StringBuffer(sgood).reverse();
return sgood.toString().equals(sgood_rev.toString());
}
}
标签:ch,StringBuffer,sgood,length,125,LeetCode,回文
From: https://www.cnblogs.com/shixuanliu/p/17069171.html