Skip to content

Commit 4d964a9

Browse files
committed
feat: valid palindrome
1 parent 3ae9ff7 commit 4d964a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-palindrome/minji-go.java

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

0 commit comments

Comments
 (0)