human
What is a code to longest Common Increasing Subsequence ( LCS + LIS ) and the other steps required given the following:
Longest Common Increasing Subsequence ( LCS + LIS ) | Returns the length and the LCIS of two arrays arr1 [ 0. . n - 1 ] and arr2 [ 0. . m - 1 ].
table [ j ] is going to store length of LCIS ending with arr2 [ j ] . We initialize it as 0 ,.
Traverse all elements of arr1 [ ].
Initialize current length of LCIS.
For each element of arr1 [ ] , traverse all elements of arr2 [ ] ..
If both the array have same elements . Note that we don 't break the loop here..
Now seek for previous smaller common element for current element of arr1.
The maximum value in table [ ] is out result.
Driver Code"
Solution in Python:
assistant
#Here is code to longest Common Increasing Subsequence ( LCS + LIS ) and the other steps required.
 def LCIS ( arr1 , n , arr2 , m ) :
	table = [ 0 ] * m
	for j in range ( m ) :
		table [ j ] = 0
	for i in range ( n ) :
		current = 0
		for j in range ( m ) :
			if ( arr1 [ i ] == arr2 [ j ] ) :
				if ( current + 1 > table [ j ] ) :
					table [ j ] = current + 1
			if ( arr1 [ i ] > arr2 [ j ] ) :
				if ( table [ j ] > current ) :
					current = table [ j ]
	result = 0
	for i in range ( m ) :
		if ( table [ i ] > result ) :
			result = table [ i ]
	return result
if __name__ == " _ _ main _ _ " :
	arr1 = [ 3 , 4 , 9 , 1 ]
	arr2 = [ 5 , 3 , 8 , 9 , 10 , 2 , 1 ]
	n = len ( arr1 )
	m = len ( arr2 )
	print ( " Length ▁ of ▁ LCIS ▁ is " , LCIS ( arr1 , n , arr2 , m ) )