Using Dynamic programing(Longest common subsequence logic) we can solve this problem in O(nm) where n is the length of the first string and m is the length of second string. Last element of matrix which the length of the string that matches.
http://codepad.org/cyiKEMSF <http://codepad.org/cyiKEMSF> On Sun, Aug 1, 2010 at 8:13 AM, srikanth sg <srikanthini...@gmail.com>wrote: > plz .. if any one knows dp solution then tell ... > > > On Sun, Aug 1, 2010 at 7:31 AM, Ashim Kapoor <ashimkap...@gmail.com>wrote: > >> I am not sure, but can I do this using a suffix trie ? any comments ? >> >> >> >> >> On Sun, Aug 1, 2010 at 2:29 PM, Ashish Goel <ashg...@gmail.com> wrote: >> >>> solution could be to find the charcter position from both sides for each >>> char of s2 >>> then from the 2*n array, find the smallest index from left and largest >>> from right, within these two indexes all chars would be there >>> >>> one case where one of the chars can be missing can be found if a row in >>> this 2-d array remains unmodified >>> >>> >>> >>> Best Regards >>> Ashish Goel >>> "Think positive and find fuel in failure" >>> +919985813081 >>> +919966006652 >>> >>> >>> >>> On Sat, Jul 31, 2010 at 10:22 PM, Nikhil Jindal >>> <fundoon...@yahoo.co.in>wrote: >>> >>>> At the moment, I can only think of an O(n^3) algo. >>>> Maybe if you can find a hash function which computes the hash value >>>> depending on the unique characters the string contains, you can reduce it >>>> to >>>> O(n^2). >>>> >>>> >>>> On Sat, Jul 31, 2010 at 7:09 PM, srikanth sg >>>> <srikanthini...@gmail.com>wrote: >>>> >>>>> given two string , find the minimum width in string 1 containing the >>>>> all characters of string 2 , they may present in different order >>>>> string 1-HELLO >>>>> string 2- LE >>>>> answer-2 >>>>> >>>>> -- >>>>> 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. >>>>> >>>>> >>>> Please access the attached hyperlink for an important electronic >>>> communications disclaimer: >>>> http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> >>>> 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<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<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<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.