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 a77366c commit 7f2aef5Copy full SHA for 7f2aef5
EASY/src/easy/ValidPalindrome.java
@@ -0,0 +1,17 @@
1
+package easy;
2
+
3
+public class ValidPalindrome {
4
5
+ public boolean isPalindrome(String s) {
6
+ int i = 0, j = s.length()-1;
7
+ char[] chars = s.toCharArray();
8
+ while(i < j){
9
+ while(i < j && !Character.isLetterOrDigit(chars[i])) i++;
10
+ while(i < j && !Character.isLetterOrDigit(chars[j])) j--;
11
+ if(Character.toLowerCase(chars[i]) != Character.toLowerCase(chars[j])) return false;
12
+ i++; j--;
13
+ }
14
+ return true;
15
16
17
+}
0 commit comments