From 690028e3feb2e69c3361353cde2e2277f0bfa968 Mon Sep 17 00:00:00 2001 From: Anushka Dube <75694963+Anushka-3000@users.noreply.github.com> Date: Wed, 6 Oct 2021 11:17:03 +0530 Subject: [PATCH] Code for Valid Palindrome --- Valid Palindrome.py | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Valid Palindrome.py diff --git a/Valid Palindrome.py b/Valid Palindrome.py new file mode 100644 index 0000000..189cfeb --- /dev/null +++ b/Valid Palindrome.py @@ -0,0 +1,57 @@ +class Solution(object): + + def isPalindrome(self, s): + + """ + + :type s: str + + :rtype: bool + + """ + + l=len(s) + + + + i=0 + + j=l-1 + + + + while i<=j: + + ia=s[i] + + ja=s[j] + + + + if not ia.isalnum(): + + i+=1 + + continue + + if not ja.isalnum(): + + j-=1 + + continue + + + + if ia.lower()!=ja.lower(): + + return False + + + + i+=1 + + j-=1 + + return True + +