Skip to content

Commit bdabb3c

Browse files
authored
Create 。。。.md
1 parent 0f9bb82 commit bdabb3c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

2018.11.27-leetcode125/。。。.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
public boolean isPalindrome(String s){
2+
if (s.length() >= 2){
3+
int left = 0,right = s.length()-1;
4+
char leftChar,rightChar;
5+
while (left <= right){
6+
leftChar = s.charAt(left);rightChar = s.charAt(right);
7+
if (leftChar>='A'&&leftChar<='Z'){//转换大写字母为小写
8+
leftChar+=32;
9+
}else if (rightChar>='A'&&rightChar<='Z'){
10+
rightChar+=32;
11+
}
12+
if (leftChar == rightChar){
13+
left++;right--;
14+
continue;
15+
}
16+
//跳过非字母非数字的字符
17+
if (!((leftChar>='0'&& leftChar<='9') || (leftChar>='a'&&leftChar<='z') || (leftChar>='A'&&leftChar<='Z'))){
18+
left++;
19+
continue;
20+
}else if (!((rightChar>='0'&& rightChar<='9') || (rightChar>='a'&&rightChar<='z') || (rightChar>='A'&&rightChar<='Z'))){
21+
right--;
22+
continue;
23+
}
24+
if (leftChar != rightChar)return false;
25+
}
26+
}
27+
return true;
28+
}

0 commit comments

Comments
 (0)