AlgoGenesis / C

AlgoGenesis is a centralized open-source platform dedicated to providing optimized and well-documented algorithm implementations in C. Perfect for both beginners and advanced users, this repository serves as a comprehensive learning resource for solving algorithmic challenges.
MIT License
89 stars 306 forks source link

[NEW ALGORITHM] : Longest Palindromic String #141

Closed tanushrigoel closed 1 month ago

tanushrigoel commented 1 month ago

Description:

The Longest Palindromic Substring (LPS) algorithm is used to find the longest contiguous substring in a given string that reads the same forward and backward. This is an efficient solution with a time complexity of O(n²).

Key Steps:

Complexity:

This algorithm is useful for text analysis and efficiently handles edge cases such as empty strings and single characters.

Checklist:

Additional Information:

Longest Palindromic Substring (Dynamic Programming)

Overview:

This algorithm finds the longest contiguous palindromic substring within a given string using dynamic programming.

Key Steps:

  1. DP Table: A 2D table tracks whether substrings are palindromes.
  2. Base Cases: Single-character substrings are palindromes. For two-character substrings, check if both characters match.
  3. Dynamic Update: For longer substrings, check if both ends match and if the inner substring is a palindrome.
  4. Efficiency: Time complexity is O(n²).
tanushrigoel commented 1 month ago

please add hacktoberfest label as well