Re: [algogeeks] Find even length palindrome.
@atul If we need to find the longest palindrome whether even or odd we can use DP.The recursion can look this: LP(i,j) = max( LP(i+1,j),LP(i,j-1) if(string[i]!=string[j]) max( LP(i+1,j),LP(i,j-1),LP(i+1,j-1)+1 ) else Note : Do LP(i+1,j-1)+1 only if it returns value equal to j-1.So that we can add adj characters also as they will be continuous The time will be O(n^2) and space also O(n^2).You can optimize space to O(n). Correct me if I am wrong. @Lucifier I didnt understand ur algo -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/J8hZJllMTfgJ. To post to this group, send email to algogeeks@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.
Re: [algogeeks] Find even length palindrome.
@atul I am not sure whether I got ur question correctly.If you only want to check whether an even palindrome exist or not,then u can check for whether adjacent characters are same or not.It is very simple.If you want the longest string then its gets difficult.Same algo can be also used for presence of odd palindrome with minor modification.Here u take each character and chk whether both of its neighbors are same.Both are O(n) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/8H0NSrsEJ5IJ. To post to this group, send email to algogeeks@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.
Re: [algogeeks] Find even length palindrome.
@sumit : whats your nlogn approach ??? On Wed, Dec 28, 2011 at 11:27 AM, sumit mahamuni wrote: > Here I can think of O( n * log n ). can anyone think of better solution?? > > On Tue, Dec 27, 2011 at 11:06 PM, atul007 wrote: > >> Given a string of length N, find whether there exits an even length >> palindrome substring. >> what would be efficient way of solving this problem.? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@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. >> >> > > > -- > Thanks and Regards, > Sumit Mahamuni. > > -- Slow code that scales better can be faster than fast code that doesn't > scale! > -- Tough times never lasts, but tough people do. > -- I love deadlines. I like the whooshing sound they make as they fly by. > - D. Adams > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.
Re: [algogeeks] Find even length palindrome.
http://www.allisons.org/ll/AlgDS/Tree/Suffix/#demoForm Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Dec 28, 2011 at 11:27 AM, sumit mahamuni wrote: > Slow code that scales better can be faster than fast code that doesn't > scale! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.
Re: [algogeeks] Find even length palindrome.
Here I can think of O( n * log n ). can anyone think of better solution?? On Tue, Dec 27, 2011 at 11:06 PM, atul007 wrote: > Given a string of length N, find whether there exits an even length > palindrome substring. > what would be efficient way of solving this problem.? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > > -- Thanks and Regards, Sumit Mahamuni. -- Slow code that scales better can be faster than fast code that doesn't scale! -- Tough times never lasts, but tough people do. -- I love deadlines. I like the whooshing sound they make as they fly by. - D. Adams -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.
Re: [algogeeks] Find even length palindrome.
one solution could be :- hash every even number substring , starting from beginning. after this. hash every even number substring , starting from end. if it exists..means palindrome exists. complexity would be O(N^2). On Tue, Dec 27, 2011 at 11:06 PM, atul007 wrote: > Given a string of length N, find whether there exits an even length > palindrome substring. > what would be efficient way of solving this problem.? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.
[algogeeks] Find even length palindrome.
Given a string of length N, find whether there exits an even length palindrome substring. what would be efficient way of solving this problem.? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.