Skip to content

Commit fe10e8f

Browse files
committed
valid-palindrome solution
1 parent 8901b1d commit fe10e8f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

valid-palindrome/mintheon.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public boolean isPalindrome(String s) {
3+
int start = 0;
4+
int end = s.length() - 1;
5+
6+
while(start < end) {
7+
if(!Character.isLetterOrDigit(s.charAt(start))) {
8+
start++;
9+
continue;
10+
}
11+
12+
if(!Character.isLetterOrDigit(s.charAt(end))){
13+
end--;
14+
continue;
15+
}
16+
17+
if(Character.toLowerCase(s.charAt(start)) != Character.toLowerCase(s.charAt(end))) {
18+
return false;
19+
}
20+
21+
start++;
22+
end--;
23+
}
24+
25+
return true;
26+
}
27+
}

0 commit comments

Comments
 (0)