125. 有效回文 | LeetCode | Top Interview 150 | Coding Questions
发布: (2025年12月29日 GMT+8 06:31)
1 min read
原文: Dev.to
Source: Dev.to
问题
解法
class Solution {
public boolean isPalindrome(String s) {
s = s.toLowerCase();
int left = 0;
int right = s.length() - 1;
while (left = 'a' && chLeft = '0' && chLeft = 'a' && chRight = '0' && chRight <= '9')) {
right--;
continue;
}
// Compare the current characters
if (chLeft != chRight) {
return false;
}
left++;
right--;
}
return true;
}
}