Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
one of my friend encountered this question in ACHERON's technical interview.the questioner had asked to display the longest palindrome in a given string.
for example:"nitinwearsottoeverytime"-no spaces.
where nitin and otto are the two possible palindrome and since nitin is 5characters and long,it must bedisplayed.
what is the code to perform this?
do explain the logic to clear this!
Posted

You can find the the longest palindrome using Manacher's Algorithm in O(n) time! Its implementation can be found here
For input String s = "HYTBCABADEFGHABCDEDCBAGHTFYW1234567887654321ZWETYGDE". It finds the correct output which is 1234567887654321.
 
Share this answer
 
v2
Comments
Member 1097736 1-Oct-14 9:17am    
could you explain how it performs logic stepwise?
For a good explanation of the logic in solving this problem in linear time: [^].

For many implementations in C#: [^].
 
Share this answer
 
Comments
Member 1097736 1-Oct-14 9:08am    
could you explain how it performs logic stepwise?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900