-
Notifications
You must be signed in to change notification settings - Fork 0
/
125.py
63 lines (57 loc) · 1.12 KB
/
125.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# class Solution(object):
# def isPalindrome(self, s):
# """
# :type s: str
# :rtype: bool
# """
# s=s.lower()
# ss=''
# for letter in s:
# if letter.isalnum():
# # if (letter not in 'abcdefghijklmnopqrstuvwxyz') or ~letter.isdigit():
# ss+=letter
# print(ss)
#
# if ss==ss[::-1]:
# return True
# else:
# return False
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s=s.lower()
i,j=0,len(s)-1
while i<j:
while not s[i].isalnum() and i<j:
i+=1
while not s[j].isalnum() and i<j:
j-=1
print(i,j)
if s[i]!=s[j]:
return False
else:
i+=1
j-=1
return True
#%%
s =".,"
x=Solution
x.isPalindrome(x,s)
#%%
list=str(-122)
#%%
list[::-1]
#%%
a=['b','c','x','a']
a.sort()
#%%
d={a:'a'}
'a' in d
#%%
'asdfasdf'[:4]
#%%
for i in range(10,-1,-1):
print(i)