Skip to content

Commit

Permalink
add test file for workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
terri1102 committed Jul 26, 2024
1 parent 314d479 commit 683f606
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions l_125_valid_palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution:
def isPalindrome(self, s: str) -> bool:
s = [an.lower() for an in s if an.isalnum()]
if len(s) & 1 == 1:
front = "".join(s[:len(s)//2][::-1])
back = "".join(s[len(s)//2+1:])
else:
front = "".join(s[:len(s)//2][::-1])
back = "".join(s[len(s)//2:])

if front == back:
return True
return False

s = Solution()
print(s.isPalindrome("A man, a plan, a canal: Panama"))
print(s.isPalindrome("A"))
print(s.isPalindrome(" "))

0 comments on commit 683f606

Please sign in to comment.