Example :
String = “ababacadcde”
palindromes:
“a” - 4,
“b” - 2,
“aba” - 2,
“bab” - 1,
“aca” - 1,
“c” - 2,
“dcd” - 1,
“e” - 1
the string can have a length up to 10^5.you can assume that the string contains only 8 unique characters and we know what those characters are.
Also i don’t need the actual string, i only need the count of each of them and you can ignore the palindromes which only have a count of 1.
so what i need is 4,2,2,2.
What algorithm can be used? can it be done using suffix arrays.
Edit: ans mod 10^7 as it can get huge