human
Count possible permutations of given array satisfying the given conditions | Function to get the value of binomial coefficient.
Stores the value of binomial coefficient.
Since C ( N , R ) = C ( N , N - R ).
Calculate the value of C ( N , R ).
Function to get the count of permutations of the array that satisfy the condition.
Stores the value of C ( 2 N , N ).
Stores the value of catalan number.
Return answer.
Driver Code"
Solution in Python:
assistant
#Here is code to count possible permutations of given array satisfying the given conditions and the other steps required.
 def binCoff ( N , R ) :
	res = 1
	if ( R > ( N - R ) ) :
		R = ( N - R )
	for i in range ( R ) :
		res *= ( N - i )
		res //= ( i + 1 )
	return res
def cntPermutation ( N ) :
	C_2N_N = binCoff ( 2 * N , N )
	cntPerm = C_2N_N // ( N + 1 )
	return cntPerm
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 ]
	N = len ( arr )
	print ( cntPermutation ( N // 2 ) )