# Valid Palindrome String | LeetCode | InterviewBit | Solution

```class Solution:
def isPalindrome(self, s):
ns = ""
for c in s.lower():
c = c
if 'a' <= c <= 'z' or '0' <= c <= '9':
ns += c
return int(ns == ns[::-1])```
```class Solution:
def isPalindrome(self, s: str) -> bool:
l, r = 0, len(s)-1
s = s.lower()
while l < r:
if s[l] == s[r]:
l += 1
r -= 1
elif not ('a' <= s[l] <= 'z' or '0' <= s[l] <= '9'):
l += 1
elif not ('a' <= s[r] <= 'z' or '0' <= s[r] <= '9'):
r -= 1
else:
return False
return True```
##### Tanishq Chaudhary Producing high-quality intuitive explanations of interview problems. Currently covering LeetCode and InterviewBit.

### Recommended Posts

##### Gas Station | InterviewBit | Solution Explained

June 13, 2022

##### Majority Element | InterviewBit | Solution Explained

June 13, 2022

##### Assign Mice to Holes | InterviewBit | Solution Explained

June 13, 2022

1. Srishti Chopra :July 23, 2022 at 11:29 am

2. Makarand :August 16, 2022 at 11:06 am
3. Gopal :November 14, 2022 at 5:53 pm