Skip to content

Optimize palindrome check using two-pointer approach#3173

Open
ANIKET640-a11y wants to merge 1 commit into
TheAlgorithms:masterfrom
ANIKET640-a11y:first-cpp-contribution
Open

Optimize palindrome check using two-pointer approach#3173
ANIKET640-a11y wants to merge 1 commit into
TheAlgorithms:masterfrom
ANIKET640-a11y:first-cpp-contribution

Conversation

@ANIKET640-a11y

@ANIKET640-a11y ANIKET640-a11y commented Jun 15, 2026

Copy link
Copy Markdown

Describe your change:

Fixes #3170

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

Replaced the string reversal approach with a two-pointer technique for palindrome checking. This reduces the auxiliary space complexity from O(n) to O(1) while maintaining O(n) time complexity.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file.
  • All filenames are in lowercase characters with no spaces or dashes.

@ANIKET640-a11y ANIKET640-a11y marked this pull request as draft June 15, 2026 05:36
@ANIKET640-a11y ANIKET640-a11y marked this pull request as ready for review June 15, 2026 05:37
Sign up for free to 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.

Suggestion to the code

1 participant