human
Find first k natural numbers missing in given array | Prints first k natural numbers in arr [ 0. . n - 1 ].
Find first positive number.
Now find missing numbers between array elements.
Find missing numbers after maximum ..
Driver code"
How can the above be solved in Python?
 ... Can you provide a code to find first k natural numbers missing in given array and the other steps required?
assistant
#Here is code to find first k natural numbers missing in given array and the other steps required.
 def printKMissing ( arr , n , k ) :
	arr . sort ( )
	i = 0
	while ( i < n and arr [ i ] <= 0 ) :
		i = i + 1
	count = 0
	curr = 1
	while ( count < k and i < n ) :
		if ( arr [ i ] != curr ) :
			print ( str ( curr ) + " ▁ " , end = ' ' )
			count = count + 1
		else :
			i = i + 1
		curr = curr + 1
	while ( count < k ) :
		print ( str ( curr ) + " ▁ " , end = ' ' )
		curr = curr + 1
		count = count + 1
arr = [ 2 , 3 , 4 ]
n = len ( arr )
k = 3
printKMissing ( arr , n , k ) ;