Hi,
I think you have misread the problem. You are allowed to take away letters from
the middle of the input string. So, for ADAM, you have to check
AAM (D is removed)
ADM (A is removed)
in addition to the usual substrings (i.e. strings formed by taking away letters
from the beginning or the
Are you really sure that your assumption is correct?
I am not sure about the fact that you can take sub strings from the word by
removing characters from between them...
AAM is certainly not valid sub string for this case as far as my
understanding of the problem stands.
On 3/30/07, Muntasir Azam
Yes, i read the problem again. My interpretation was incorrect.
Generally one tends to interpret a problem in a way it's a bit easier to
understand :D. That happened with me on this occasion.
It's a pretty complex problem from where i see it. and time limit:10
seconds!!! Seems rather too less...
Oh I think i wasn't thinking straight...
I think the problem can be solved by simply removing 'i' letters from the
string and check if that is a palendrome. where i would go from 1 to lenght.
But when i 1...will i need to select all possible 2 length strings from
the word and remove them one by
I second that. I believe O(n^2) is a correct call.
Consider a function LONGEST_PALINDROME (left, right), where it accepts the
substring definition based on left and right, and will return the maximum
length of palindrome which can be generated from that substring:
LONGEST_PALINDROME (left,