Build a Palindrome

  • + 2 comments

    Hey guys, I think the easiest (and the most logical) approach would be to use suffix trees. This problem is naturally reduced to "longest common substring" problem if you reverse the second string. There is time- and space-efficient O(n + m) solution for that, using Ukkunen's algorithm. But unfortunately the algorithm is quite complex.

    Based on the length of input (~10^5), no O(n^2) algorithm will work here. Maybe O(n*log(n)) will still do...