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.
2 parents b2b9712 + dd41204 commit 391efe4Copy full SHA for 391efe4
valid-palindrome/JEONGBEOMKO.java
@@ -0,0 +1,32 @@
1
+class Solution {
2
+
3
+ /*
4
+ time complexity: O(n)
5
+ space complexity: O(n)
6
+ */
7
8
+ public boolean isPalindrome(String s) {
9
10
+ int left = 0;
11
+ int right = s.length() - 1;
12
13
+ while (left < right) {
14
+ while (left < right && !Character.isLetterOrDigit(s.charAt(left))) {
15
+ left++;
16
+ }
17
18
+ while (left < right && !Character.isLetterOrDigit(s.charAt(right))) {
19
+ right--;
20
21
22
+ if (Character.toLowerCase(s.charAt(left)) != Character.toLowerCase(s.charAt(right))) {
23
+ return false;
24
25
26
27
28
29
30
+ return true;
31
32
+}
0 commit comments