Skip to content

Add Manacher’s Algorithm for Longest Palindromic Substring #5462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 24, 2024

Conversation

donutz03
Copy link
Contributor

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

This PR adds Manacher's Algorithm to find the longest palindromic substring in linear time.

Closes #5453

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.28%. Comparing base (2643ab5) to head (d8dabd8).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5462      +/-   ##
============================================
+ Coverage     52.18%   52.28%   +0.09%     
- Complexity     3245     3255      +10     
============================================
  Files           524      525       +1     
  Lines         15156    15183      +27     
  Branches       2881     2887       +6     
============================================
+ Hits           7909     7938      +29     
+ Misses         6921     6920       -1     
+ Partials        326      325       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

donutt03 and others added 3 commits September 24, 2024 12:31
- Added parameterized tests for longestPalindrome, empty cases, complex cases, and sentence palindromes.
- Removed unnecessary comments for cleaner code.
- Renamed variable `p` to `palindromeLengths` for clarity based on code review feedback.
Copy link
Contributor Author

@donutz03 donutz03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved all comments. Changed files to support review.

@alxkm
Copy link
Contributor

alxkm commented Sep 24, 2024

Thank you for your contribution

@alxkm alxkm merged commit 1460eb7 into TheAlgorithms:master Sep 24, 2024
6 checks passed
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.

[FEATURE REQUEST] <title>Add a new Algorithm Manacher’s Algorithm
4 participants