Skip to content

Commit ab7172a

Browse files
committed
🎨 Valid Palindrome Solution
1 parent d2c0fca commit ab7172a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

valid-palindrome/dalpang81.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+
s = s.toLowerCase().trim();
4+
s = s.replaceAll("[^a-z0-9]", "");
5+
6+
StringBuffer sb = new StringBuffer(s);
7+
String reverse = sb.reverse().toString();
8+
9+
return(s.equals(reverse));
10+
11+
}
12+
}

0 commit comments

Comments
 (0)