From 33036fe057ae78eba898d0905464dec811bf0281 Mon Sep 17 00:00:00 2001 From: hema_ameh <152301559+PYDIMARRI-HEMA-HARSHINI-23-586@users.noreply.github.com> Date: Tue, 2 Sep 2025 21:09:35 +0530 Subject: [PATCH 1/4] Fix: is_palindrome_recursive logic for 2-char strings --- strings/palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/palindrome.py b/strings/palindrome.py index bfdb3ddcf396..608625e11d8e 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -61,7 +61,7 @@ def is_palindrome_recursive(s: str) -> bool: >>> all(is_palindrome_recursive(key) is value for key, value in test_data.items()) True """ - if len(s) <= 2: + if len(s) <= 1: return True if s[0] == s[len(s) - 1]: return is_palindrome_recursive(s[1:-1]) From c3c8ad0e66a6ff6c62732197f2c09c397d41e21a Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Thu, 4 Sep 2025 03:42:11 +0300 Subject: [PATCH 2/4] Update palindrome.py --- strings/palindrome.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/palindrome.py b/strings/palindrome.py index 608625e11d8e..071c182b3061 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -11,6 +11,7 @@ "BB": True, "ABC": False, "amanaplanacanalpanama": True, # "a man a plan a canal panama" + "abcdba": False, } # Ensure our test data is valid 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: >>> all(is_palindrome_recursive(key) is value for key, value in test_data.items()) True """ - if len(s) <= 1: + if len(s) <= 2: return True if s[0] == s[len(s) - 1]: return is_palindrome_recursive(s[1:-1]) From c82d6b3934101e4506ac0c6044ca1d52f98b576d Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Thu, 4 Sep 2025 03:45:00 +0300 Subject: [PATCH 3/4] Update palindrome.py --- strings/palindrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/palindrome.py b/strings/palindrome.py index 071c182b3061..9ed2c1c9425d 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -62,7 +62,7 @@ def is_palindrome_recursive(s: str) -> bool: >>> all(is_palindrome_recursive(key) is value for key, value in test_data.items()) True """ - if len(s) <= 2: + if len(s) <= 1: return True if s[0] == s[len(s) - 1]: return is_palindrome_recursive(s[1:-1]) From 40d72d52ecbeab72dca3c3e778a734f5912b007c Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Thu, 4 Sep 2025 03:46:24 +0300 Subject: [PATCH 4/4] Update palindrome.py --- strings/palindrome.py | 1 + 1 file changed, 1 insertion(+) diff --git a/strings/palindrome.py b/strings/palindrome.py index 9ed2c1c9425d..e765207e5942 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -12,6 +12,7 @@ "ABC": False, "amanaplanacanalpanama": True, # "a man a plan a canal panama" "abcdba": False, + "AB": False, } # Ensure our test data is valid assert all((key == key[::-1]) is value for key, value in test_data.items())