Skip to content

Conversation

@PYDIMARRI-HEMA-HARSHINI-23-586
Copy link
Contributor

Fix#12941 : Corrected base case in is_palindrome_recursive in strings/palindrome.py of Python directory.

Previously, the base case used if len(s) <= 2: return True, which incorrectly treated any 2-character string as a palindrome (for example, "AB" returned True). Updated the base case to len(s) <= 1 so that two-character strings are compared for equality and only empty/single-character strings auto-pass.

@algorithms-keeperalgorithms-keeperbot added the awaiting reviews This PR is ready to be reviewed label Sep 4, 2025
@MaximSmolskiyMaximSmolskiy changed the title Fix: is_palindrome_recursive logic for 2-char strings in strings/palindrome.pyFix is_palindrome_recursive logic in strings/palindrome.pySep 4, 2025
@algorithms-keeperalgorithms-keeperbot added the tests are failing Do not merge until tests pass label Sep 4, 2025
@algorithms-keeperalgorithms-keeperbot removed the tests are failing Do not merge until tests pass label Sep 4, 2025
@algorithms-keeperalgorithms-keeperbot removed the awaiting reviews This PR is ready to be reviewed label Sep 4, 2025
@MaximSmolskiyMaximSmolskiy merged commit 544f48f into TheAlgorithms:masterSep 4, 2025
5 of 6 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong palindrome implementation

3 participants

@PYDIMARRI-HEMA-HARSHINI-23-586@MaximSmolskiy@mindaugl