TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of Manacher's Algorithm More...
#include <cassert>
#include <cstdint>
#include <iostream>
#include <vector>
#include <cstring>
Go to the source code of this file.
Namespaces | |
namespace | strings |
String algorithms. | |
namespace | manacher |
Functions for Manacher's Algorithm implementation. | |
Functions | |
std::string | strings::manacher::manacher (const std::string &prototype) |
A function that implements Manacher's algorithm. | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
Implementation of Manacher's Algorithm
Manacher's Algorithm is used to find the longest palindromic substring within a string in O(n) time. It exploits the property of a palindrome that its first half is symmetric to the last half, and thus if the first half is a palindrome, then last half is also a palindrome.
Definition in file manacher_algorithm.cpp.
int main | ( | void | ) |
Main function.
Definition at line 172 of file manacher_algorithm.cpp.
std::string strings::manacher::manacher | ( | const std::string & | prototype | ) |
A function that implements Manacher's algorithm.
prototype | is the string where algorithm finds a palindromic substring. This string can contain any character except @ # & |
Definition at line 41 of file manacher_algorithm.cpp.
|
static |
Self-test implementations.
Definition at line 151 of file manacher_algorithm.cpp.