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 4e46337 commit dabcb5fCopy full SHA for dabcb5f
1 file changed
valid-palindrome/essaysir.java
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ public boolean isPalindrome(String s) {
3
+ StringBuilder sb = new StringBuilder();
4
+ for (char c : s.toCharArray()) {
5
+ if (Character.isLetterOrDigit(c)) {
6
+ sb.append(Character.toLowerCase(c));
7
+ }
8
9
+
10
+ String result = sb.toString();
11
+ char[] x = result.toCharArray();
12
+ for (int i = 0; i < x.length / 2; i++) {
13
+ if (x[i] != x[x.length - i - 1]) {
14
+ return false;
15
16
17
+ return true;
18
19
+}
0 commit comments