Longest common substring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balanivash
    New Member
    • Apr 2010
    • 2

    Longest common substring

    Hi...
    could anyone help in finding the best algorithm for finding the longest common sub-string in two strings.....I'm familiar with the efficient algorithm to find the longest common sub-sequence and i tried modifying the same a bit to make it work for sub-string but i dont get the correct results...


    Balanivash
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    strspn() returns the length of the longest substring of s1 that begins with s[0] and contains only characters found in s2. But I`m not sure that this is what you really want.

    Comment

    • balanivash
      New Member
      • Apr 2010
      • 2

      #3
      Originally posted by whodgson
      strspn() returns the length of the longest substring of s1 that begins with s[0] and contains only characters found in s2. But I`m not sure that this is what you really want.
      Dear Mr.Whodgson

      strspn finds the length of the substring in s1 which has charcters from s2....but what i want is to find the substring which is common to both the strings....But thank you very much for your reply..

      Balanivash

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        Could you write out the most efficient method you have (in words, not code)? We might be able to see where you're slipping up with the implementation.

        There are some code examples in wikipedia:

        Comment

        Working...