Add the least amount of characters to make a palindrome
The question: Given any string, add the least amount of characters possible to make it a palindrome in linear time. I'm only able to come up with a O(N 2 ) solution. Can someone help me with an O(N) solution? Chronial Revert the string Use a modified Knuth-Morris-Pratt to find the latest match (simplest modification would be to just append the original string to the reverted string and ignore matches after len(string). Append the unmatched rest of the reverted string to the original. 1 and 3 are obviously linear and 2 is linear beacause Knuth-Morris-Pratt is. If only appending is allowed A