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 9ae391a commit 7cd50c8Copy full SHA for 7cd50c8
valid-palindrome/ohgyulim.java
@@ -0,0 +1,21 @@
1
+class Solution {
2
+ public boolean isPalindrome(String s) {
3
+ StringBuilder sb = new StringBuilder();
4
+
5
+ for (char ch : s.toCharArray()) {
6
+ if (Character.isLetterOrDigit(ch)) {
7
+ sb.append(Character.toLowerCase(ch));
8
+ }
9
10
11
+ for (int i = 0; i < sb.length(); i++) {
12
+ int left = i;
13
+ int right = sb.length() - i - 1;
14
15
+ if (left >= right) return true;
16
+ if (sb.charAt(left) != sb.charAt(right)) return false;
17
18
19
+ return true;
20
21
+}
0 commit comments