human
Give me a code to divide array into increasing and decreasing subsequence without changing the order and the other steps required given the following:
Divide array into increasing and decreasing subsequence without changing the order | Function to print strictly increasing and strictly decreasing sequence if possible.
Arrays to store strictly increasing and decreasing sequence.
Initializing last element of both sequence.
Iterating through the array.
If current element can be appended to both the sequences.
If next element is greater than the current element Then append it to the strictly increasing array.
Otherwise append it to the strictly decreasing array.
If current element can be appended to the increasing sequence only.
If current element can be appended to the decreasing sequence only.
Else we can not make such sequences from the given array.
Print the required sequences.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to divide array into increasing and decreasing subsequence without changing the order and the other steps required.
 def Find_Sequence ( array , n ) :
	inc_arr , dec_arr = [ ] , [ ]
	inc , dec = - 1 , 1e7
	for i in range ( n ) :
		if inc < array [ i ] < dec :
			if array [ i ] < array [ i + 1 ] :
				inc = array [ i ]
				inc_arr . append ( array [ i ] )
			else :
				dec = array [ i ]
				dec_arr . append ( array [ i ] )
		elif inc < array [ i ] :
			inc = array [ i ]
			inc_arr . append ( array [ i ] )
		elif dec > array [ i ] :
			dec = array [ i ]
			dec_arr . append ( array [ i ] )
		else :
			print ( ' - 1' )
			break
	else :
		print ( inc_arr , dec_arr )
arr = [ 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 ]
n = len ( arr )
Find_Sequence ( arr , n )