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.
2 parents f39f142 + bcb9ff5 commit 463d3aaCopy full SHA for 463d3aa
2018.11.26/湛江甲鸟.md
@@ -0,0 +1,35 @@
1
+```
2
+public boolean isPalindrome(String s) {
3
+ char[] chars = s.toLowerCase().toCharArray();
4
+ int start = 0;
5
+ int end = chars.length - 1;
6
+ while (start < end) {
7
+ char ch1 = chars[start];
8
+ char ch2 = chars[end];
9
+ if (!isLetterOrNum(ch1)) {
10
+ start++;
11
+ } else if (!isLetterOrNum(ch2)){
12
+ end--;
13
+ } else {
14
+ if (ch1 == ch2) {
15
16
17
+
18
19
+ return false;
20
+ }
21
22
23
24
25
+ return true;
26
+}
27
28
+public static boolean isLetterOrNum(char ch) {
29
+ String pattern = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
30
+ if (pattern.contains(String.valueOf(ch))) {
31
32
33
34
35
0 commit comments