|
Csd 1.1.4; VERSION ${PROJECT_VERSION}
|
Functions for finding repeated substrings. More...
Functions | |
| auto | csd::longest_repeated_substring (const char *sv, size_t len) -> std::string |
| Find the longest repeated non-overlapping substring. | |
Functions for finding repeated substrings.
|
extern |
Find the longest repeated non-overlapping substring.
This function finds the longest substring that appears at least twice in the input string, with the constraint that the occurrences must not overlap. It uses a dynamic programming approach with optimized space complexity.
The algorithm builds a 2D table where each cell [i][j] stores the length of the longest common substring ending at positions i-1 and j-1, but only if the substrings don't overlap (j-i > lcsre[i-1][j-1]).
Example:
| [in] | sv | Pointer to a null-terminated character array representing the input string. The string should contain valid ASCII or UTF-8 characters. |
| [in] | len | Length of the input string. Must be non-negative and should match the actual length of the string (excluding null terminator). |
| std::invalid_argument | If sv is nullptr or if len doesn't match the actual string length. |