I found one algorithm problem. I solved that problem, but I want to optimize that. I ask the same problem here.
Problem
One String is given and the length of that string is N <= 10000000. All characters of that string is from 'a' to 'z'. Now we have to calculate smallest palindrome that we can make from given string by adding characters the end.
Example
Given String = 'abab'
Output = 'ababa'
Reasoning: the string ababa
contains the string abab
starting from both the beginning and end of the string, with only 1 extra character on each end.
Edited
String = 'abbcd' Output = 'abbcdcbba'
My attemp
I can solve this problem in O(N^2) complexity.
My question
Can I solve this problem in less than O(N^2) time ? , If yes, than what is the algorithm? (Give me a hint)