Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 544f48f

Browse files
PYDIMARRI-HEMA-HARSHINI-23-586MaximSmolskiy
andauthored
Fix is_palindrome_recursive logic in strings/palindrome.py (#12946)
* Fix: is_palindrome_recursive logic for 2-char strings * Update palindrome.py * Update palindrome.py * Update palindrome.py --------- Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
1 parent 0876a87 commit 544f48f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎strings/palindrome.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"BB": True,
1212
"ABC": False,
1313
"amanaplanacanalpanama": True, # "a man a plan a canal panama"
14+
"abcdba": False,
15+
"AB": False,
1416
}
1517
# Ensure our test data is valid
1618
assert all((key == key[::-1]) is value for key, value in test_data.items())
@@ -61,7 +63,7 @@ def is_palindrome_recursive(s: str) -> bool:
6163
>>> all(is_palindrome_recursive(key) is value for key, value in test_data.items())
6264
True
6365
"""
64-
if len(s) <= 2:
66+
if len(s) <= 1:
6567
return True
6668
if s[0] == s[len(s) - 1]:
6769
return is_palindrome_recursive(s[1:-1])

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /