human
What is a code to longest Common Substring and the other steps required given the following:
Longest Common Substring | DP | Returns length of longest common substring of X [ 0. . m - 1 ] and Y [ 0. . n - 1 ].
Create a table to store lengths of longest common suffixes of substrings . Note that LCSuff [ i ] [ j ] contains the length of longest common suffix of X [ 0. . . i - 1 ] and Y [ 0. . . j - 1 ] . The first row and first column entries have no logical meaning , they are used only for simplicity of the program ..
To store the length of longest common substring.
Following steps to build LCSuff [ m + 1 ] [ n + 1 ] in bottom up fashion.
Driver Code"
Solution in Python:
assistant
#Here is code to longest Common Substring and the other steps required.
 def LCSubStr ( X , Y , m , n ) :
	LCSuff = [ [ 0 for k in range ( n + 1 ) ] for l in range ( m + 1 ) ]
	result = 0
	for i in range ( m + 1 ) :
		for j in range ( n + 1 ) :
			if ( i == 0 or j == 0 ) :
				LCSuff [ i ] [ j ] = 0
			elif ( X [ i - 1 ] == Y [ j - 1 ] ) :
				LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1
				result = max ( result , LCSuff [ i ] [ j ] )
			else :
				LCSuff [ i ] [ j ] = 0
	return result
X = ' OldSite : GeeksforGeeks . org '
Y = ' NewSite : GeeksQuiz . com '
m = len ( X )
n = len ( Y )
print ( ' Length ▁ of ▁ Longest ▁ Common ▁ Substring ▁ is ' , LCSubStr ( X , Y , m , n ) )