human
Longest Common Substring | DP | Returns length of function for longest common substring of X [ 0. . m - 1 ] and Y [ 0. . n - 1 ].
Driver code"
How can the above be solved in Python?
assistant
#Here is code to longest Common Substring and the other steps required.
 def lcs ( i , j , count ) :
	if ( i == 0 or j == 0 ) :
		return count
	if ( X [ i - 1 ] == Y [ j - 1 ] ) :
		count = lcs ( i - 1 , j - 1 , count + 1 )
	count = max ( count , max ( lcs ( i , j - 1 , 0 ) , lcs ( i - 1 , j , 0 ) ) )
	return count
if __name__ == " _ _ main _ _ " :
	X = " abcdxyz "
	Y = " xyzabcd "
	n = len ( X )
	m = len ( Y )
	print ( lcs ( n , m , 0 ) )