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 c620f71 commit ca075efCopy full SHA for ca075ef
1 file changed
valid-palindrome/JeonJe.java
@@ -0,0 +1,23 @@
1
+import java.util.*;
2
+
3
+// TC: O(n)
4
+// SC: O(n)
5
+class Solution {
6
+ public boolean isPalindrome(String s) {
7
+ StringBuilder sb = new StringBuilder();
8
9
+ for (char c : s.toCharArray()) {
10
+ if (Character.isLetterOrDigit(c)) {
11
+ sb.append(Character.toLowerCase(c));
12
+ }
13
14
15
+ for (int i = 0; i < sb.length() / 2; i++) {
16
+ if (sb.charAt(i) != sb.charAt(sb.length() - 1 - i)) {
17
+ return false;
18
19
20
+ return true;
21
22
23
+}
0 commit comments