Skip to content

Commit d740e70

Browse files
committed
feat: valid-palindrome solution
1 parent 6df5759 commit d740e70

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

valid-palindrome/sm9171.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public boolean isPalindrome(String s) {
3+
String str = s.toLowerCase().replaceAll("[^a-z0-9]","");
4+
char[] charArray = str.toCharArray();
5+
for (int i = 0; i < charArray.length / 2; i++) {
6+
if (charArray[i] != charArray[charArray.length - i - 1]) {
7+
return false;
8+
}
9+
}
10+
return true;
11+
}
12+
}

0 commit comments

Comments
 (0)