Counting distinct palindromes in a word in linear time
Résumé
We design an algorithm to count the number of distinct palindromes in a word w in time O(|w|), by adapting an algorithm to detect all occurrences of maximal palindromes in a given word and using the longest previous factor array. As a direct consequence, this shows that the palindromic richness (or fullness) of a word can be checked in linear time.