human
Queries to check if count of increasing and decreasing subarrays is same in given range | Function to check if given range have equal number of increasing as well as decreasing subarrays.
Traverse each query.
For 0 - based indexing.
Condition for same count of increasing & decreasing subarray.
Driver Code"
Solution in Python:
assistant
#Here is code to queries to check if count of increasing and decreasing subarrays is same in given range and the other steps required.
 def checkCount ( A , Q , q ) :
	for i in range ( q ) :
		L = Q [ i ] [ 0 ]
		R = Q [ i ] [ 1 ]
		L -= 1
		R -= 1
		if ( ( A [ L ] < A [ L + 1 ] ) != ( A [ R - 1 ] < A [ R ] ) ) :
			print ( " Yes " )
		else :
			print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 11 , 13 , 12 , 14 ]
	Q = [ [ 1 , 4 ] , [ 2 , 4 ] ]
	q = len ( Q )
	checkCount ( arr , Q , q )