Longest Common Substring

max common sub-string of s, t

en.wikipedia.org/wiki/Longest_common_substring_problem

max common sub-string of a

for (int i=0; i<n; i++)
   for(int j=i; j++; j<n)
     if(len = comlen(&a[i],&a[j]) > max_len)
     {
            max_len = len;
            max_i = i;
            max_j = j;
      }
 
int comlen(char *p, char * q)
{
    int len = 0;
    while(*p && *q && *p==*q) 
     {
      p++; q++;
     }   
   return len;
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License