---
tags: data_structure_python
---
# Valid Palindrome <img src="https://img.shields.io/badge/-easy-brightgreen">
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
**Note**: For the purpose of this problem, we define empty string as valid palindrome.
<ins>**Example 1:**</ins>
```
Input: "A man, a plan, a canal: Panama"
Output: true
```
<ins>**Example 2:**</ins>
```
Input: "race a car"
Output: false
```
# Solution
```python=
class Solution:
def isPalindrome(self, s: str) -> bool:
s = "".join(elt for elt in s if elt.isalnum()).lower()
pointer1 = 0
pointer2 = len(s)-1
while pointer1 < pointer2:
if s[pointer1] != s[pointer2]:
return False
else:
pointer1 += 1
pointer2 -= 1
return True
```