a not very simple solution is here:

suppose reverse of x is y
denote z = x . y (conta...)

e.g. x = 123
y = 321
z = 123321

now the problem can be transform to the following one:

let f(i) be the length of longest common prefix of the i-th prefix of
z and z as whole
now to calculate the maximum f(i) over all i's

there are more general algorithms to calculate the f(i,j): longest
common prefix of the i-th and the j-th prefix   in O(1) time

so...

2006/5/2, aj <[EMAIL PROTECTED]>:
>
> Given a binary string x of length n, find the longest prefix of x in
> linear time which is a palindrome.
>
> thx
> aj
>
>
> >
>


--
myblog: http://gnor.net/daizisheng/blog/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to