-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Bug Report for https://neetcode.io/problems/is-palindrome
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Below program working correctly locally for input "OP" but it is failing on your compiler.
public boolean isPalindrome(String s) {
String b = s.toLowerCase();
int i = 0;
int j = (s.length() -1);
while (i<=j) {
if(b.charAt(i) < 'a' || b.charAt(i) >'z') {
i++;
continue;
}
if(b.charAt(j) < 'a' || b.charAt(j) >'z') {
j--;
continue;
}
if(i == j) {
return true;
}
if(b.charAt(i) != b.charAt(j)){
return false;
} else {
i++;
j--;
}
}
return true;
}
Metadata
Metadata
Assignees
Labels
No labels