Skip to content

Commit af1e5e5

Browse files
committed
Create Valid Palindrome
1 parent 73b90cb commit af1e5e5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Valid Palindrome

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
# @param s, a string
3+
# @return a boolean
4+
def isPalindrome(self,s):
5+
s = ''.join(ch for ch in s if ch.isalnum()).lower()
6+
star = 0
7+
end = len(s)-1
8+
sign = True
9+
while(star<=end and sign):
10+
if s[star] == s[end]:
11+
star +=1
12+
end -=1
13+
else:
14+
sign = False
15+
return sign

0 commit comments

Comments
 (0)