Skip to content

Commit 07278be

Browse files
chiralevyloan
andauthored
Optimized string is_palindrome main function (#688)
Co-authored-by: loan <[email protected]>
1 parent b928e1f commit 07278be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

algorithms/strings/is_palindrome.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def is_palindrome(s):
2121
i = 0
2222
j = len(s)-1
2323
while i < j:
24-
while i < j and not s[i].isalnum():
24+
while not s[i].isalnum():
2525
i += 1
26-
while i < j and not s[j].isalnum():
26+
while not s[j].isalnum():
2727
j -= 1
2828
if s[i].lower() != s[j].lower():
2929
return False

0 commit comments

Comments
 (0)