This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def validPalindrome(self, s: str) -> bool: | |
def is_palindrome(s, left, right): | |
while left < right: | |
if s[left] != s[right]: | |
return False | |
left += 1 | |
right -= 1 | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def isPalindrome(self, s: str) -> bool: | |
new_s="".join(char for char in s if char.isalnum()).lower() | |
left=0 | |
right=len(new_s) -1 | |
while left < right: | |
if new_s[left]!=new_s[right]: | |
return False | |
left+=1 |