We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef5121b commit 44f8bd0Copy full SHA for 44f8bd0
.gitignore
@@ -1,3 +1,4 @@
1
.idea
2
+*.iml
3
venv
4
cmake-build-debug
main.py
@@ -1,22 +1,22 @@
class Solution:
def isPalindrome(self, s: str) -> bool:
chars = list(s.lower())
- l = len(chars)
+ chars_count = len(chars)
5
6
p1 = 0
7
- p2 = l - 1
8
- while p1 < l and p2 > 0 and p1 < p2:
9
- n1 = ord(chars[p1])
10
- if (n1 < 97 or n1 > 122) and (n1 < 48 or n1 > 57):
+ p2 = chars_count - 1
+ while p1 < chars_count and p2 > 0 and p1 < p2:
+ s1, s2 = chars[p1], chars[p2]
+
11
+ if not s1.isalnum():
12
p1 += 1
13
continue
14
- n2 = ord(chars[p2])
15
- if (n2 < 97 or n2 > 122) and (n2 < 48 or n2 > 57):
+ if not s2.isalnum():
16
p2 -= 1
17
18
19
- if chars[p1] != chars[p2]:
+ if s1 != s2:
20
return False
21
22
0 commit comments