Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit daf8d67

Browse files
committed
No125
1 parent 2dee84c commit daf8d67

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

leetcode/String/No125.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
head++;
21+
end--;
22+
}
23+
}
24+
return true;
25+
}
26+
}

0 commit comments

Comments
 (0)