We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2dee84c commit daf8d67Copy full SHA for daf8d67
leetcode/String/No125.java
@@ -0,0 +1,26 @@
1
+class Solution {
2
+ public boolean isPalindrome(String s) {
3
+ if(s.isEmpty()){
4
+ return true;
5
+ }
6
+ int head = 0, end = s.length() - 1;
7
+ char chead ;
8
+ char cend ;
9
+ while(head <= end){
10
+ chead = s.charAt(head);
11
+ cend = s.charAt(end);
12
+ if(!Character.isLetterOrDigit(chead)){
13
+ head++;
14
+ }else if(!Character.isLetterOrDigit(cend)){
15
+ end--;
16
+ }else{
17
+ if(Character.toLowerCase(chead) != Character.toLowerCase(cend)){
18
+ return false;
19
20
21
22
23
24
25
26
+}
0 commit comments