human
Make max elements in B [ ] equal to that of A [ ] by adding / subtracting integers in range [ 0 , K ] | Function that count the number of integers from array B such that subtracting element in the range [ 0 , K ] given any element in A.
To store the count of element.
Traverse the array B.
Traverse the array A.
Find the difference.
If difference is atmost K then increment the cnt.
Print the count.
Driver Code.
Given array A and B.
Given K.
Function call"
Solution in Python:
assistant
#Here is code to make max elements in B [ ] equal to that of A [ ] by adding / subtracting integers in range [ 0 , K ] and the other steps required.
 def countElement ( A , N , B , M , K ) :
	cnt = 0
	for i in range ( M ) :
		currentElement = B [ i ]
		for j in range ( N ) :
			diff = abs ( currentElement - A [ j ] )
			if ( diff <= K ) :
				cnt += 1
				break
	print ( cnt )
if __name__ == ' _ _ main _ _ ' :
	A = [ 100 , 65 , 35 , 85 , 55 ]
	B = [ 30 , 60 , 75 , 95 ]
	N = len ( A )
	M = len ( B )
	K = 5
	countElement ( A , N , B , M , K )