human
Find if it is possible to choose subarray that it contains exactly K even integers | Function to check if it is possible to choose a subarray that contains exactly K even integers.
Variable to store the count of even numbers.
If we have to select 0 even numbers but there is all odd numbers in the array.
If the count of even numbers is greater than or equal to K then we can select a subarray with exactly K even integers.
If the count of even numbers is less than K then we cannot select any subarray with exactly K even integers.
Driver code"
Solution in Python:
assistant
#Here is code to find if it is possible to choose subarray that it contains exactly K even integers and the other steps required.
 def isPossible ( A , n , k ) :
	countOfTwo = 0
	for i in range ( n ) :
		if ( A [ i ] % 2 == 0 ) :
			countOfTwo += 1
	if ( k == 0 and countOfTwo == n ) :
		print ( " NO " )
	elif ( countOfTwo >= k ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 4 , 5 ]
	K = 2
	N = len ( arr )
	isPossible ( arr , N , K )