Skip to content

Commit b563904

Browse files
authored
Merge pull request DaleStudy#2120 from Sol35229/main
[Sol35229] WEEK 03 solutions
2 parents 2922419 + ac45c39 commit b563904

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

valid-palindrome/Sol35229.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Stack;
2+
3+
public class Sol35229 {
4+
5+
class Solution {
6+
public boolean isPalindrome(String s) {
7+
s = s.toLowerCase().replaceAll("[^a-z0-9]", "");
8+
int left = 0;
9+
int right = s.length() - 1;
10+
while (left < right) {
11+
if (s.charAt(left) != s.charAt(right)) {
12+
return false;
13+
}
14+
left++;
15+
right--;
16+
}
17+
return true;
18+
}
19+
// boolean isLowerCase(Character c) {
20+
// return (int) c > 96 && (int) c < 123 ? true : false;
21+
// }
22+
}
23+
}
24+

0 commit comments

Comments
 (0)