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.
1 parent afd0af8 commit bcb35c2Copy full SHA for bcb35c2
valid-palindrome/donghyeon95.java
@@ -0,0 +1,16 @@
1
+/* 첫 시도
2
+ leetCode 기준 18ms
3
+ */
4
+
5
+class Solution {
6
+ public boolean isPalindrome(String s) {
7
+ // 1. remove non-alphanumeric using regex
8
+ String alphanumeric = s.replaceAll("[^a-zA-Z0-9]", "");
9
10
+ // 2. change lowerCase
11
+ String lowerCase = alphanumeric.toLowerCase();
12
13
+ // 3. compare reverse String
14
+ return lowerCase.contentEquals(new StringBuffer(lowerCase).reverse());
15
+ }
16
+}
0 commit comments