Skip to content

Commit 57ecdb9

Browse files
authored
str818
1 parent c965226 commit 57ecdb9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

2018.11.27-leetcode125/str818.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```java
2+
public boolean isPalindrome(String s) {
3+
if (s.isEmpty()) return true;
4+
int head = 0, tail = s.length() - 1;
5+
char cHead, cTail;
6+
while(head <= tail) {
7+
cHead = s.charAt(head);
8+
cTail = s.charAt(tail);
9+
if (!Character.isLetterOrDigit(cHead)) {
10+
head++;
11+
} else if(!Character.isLetterOrDigit(cTail)) {
12+
tail--;
13+
} else {
14+
if (Character.toLowerCase(cHead) != Character.toLowerCase(cTail)) {
15+
return false;
16+
}
17+
head++;
18+
tail--;
19+
}
20+
}
21+
return true;
22+
}
23+
```

0 commit comments

Comments
 (0)