human
Longest subsequence from an array of pairs having first element increasing and second element decreasing . | Function to find the length of the longest subsequence of pairs whose first element is increasing and second is decreasing.
dp [ i ] : Stores the longest subsequence upto i.
Base case.
When the conditions hold.
Finally , prthe required answer.
Driver Code.
Given Input.
Function Call"
Solution in Python:

Give me a code to longest subsequence from an array of pairs having first element increasing and second element decreasing?
assistant
#Here is code to longest subsequence from an array of pairs having first element increasing and second element decreasing .
 def longestSubSequence ( A , N ) :
	dp = [ 0 ] * N
	for i in range ( N ) :
		dp [ i ] = 1
		for j in range ( i ) :
			if ( A [ j ] [ 0 ] < A [ i ] [ 0 ] and A [ j ] [ 1 ] > A [ i ] [ 1 ] ) :
				dp [ i ] = max ( dp [ i ] , dp [ j ] + 1 )
	print ( dp [ N - 1 ] )
if __name__ == ' _ _ main _ _ ' :
	A = [ [ 1 , 2 ] , [ 2 , 2 ] , [ 3 , 1 ] ]
	N = len ( A )
	longestSubSequence ( A , N )