We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 33036fe commit c3c8ad0Copy full SHA for c3c8ad0
strings/palindrome.py
@@ -11,6 +11,7 @@
11
"BB": True,
12
"ABC": False,
13
"amanaplanacanalpanama": True, # "a man a plan a canal panama"
14
+ "abcdba": False,
15
}
16
# Ensure our test data is valid
17
assert all((key == key[::-1]) is value for key, value in test_data.items())
@@ -61,7 +62,7 @@ def is_palindrome_recursive(s: str) -> bool:
61
62
>>> all(is_palindrome_recursive(key) is value for key, value in test_data.items())
63
True
64
"""
- if len(s) <= 1:
65
+ if len(s) <= 2:
66
return True
67
if s[0] == s[len(s) - 1]:
68
return is_palindrome_recursive(s[1:-1])
0 commit comments