First of all we must read a word, and a desired size.Then we need to find the longest palindrome created by characters in this word used in order.For example for size = 7 and word = abcababac the answer is 7 (abababa).   Postscript: the size of the word is smaller than 3000.
Fastest algorithm for finding the longest palindrome subsequence
algorithms;strings;subsequences