1. first find two consecutive letters which are same.
2 point ptr1 to left character and ptr2 to right one
3. now increment ptr2 and decrement ptr1. compare if they are pointing to
same characters. if yes repeat this step
4. if no then store in length ptr2-ptr1-2
5. go to step 1 untill all consecutive same letters have been scanned. if
the new length found is greater then previous one. then discard previous one
and store in length new length.
6. return the substring with largest length


On 5 June 2010 15:04, Satya <satya...@gmail.com> wrote:

> Hi,
>
> How to find largest palindrome, which is even in length in a string.
> Complexity should be "lessthan" O(n^2).
>
> Ex;- abacbbcababac - Given string.
> 'abacbbcaba' - is the largest even length palindrome.
>
> Thanks,
> Satya
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to