human
Check if two arrays can be made equal by swapping pairs of one of the arrays | Function to check if two arrays can be made equal or not by swapping pairs of only one of the arrays.
Stores elements required to be replaced.
To check if the arrays can be made equal or not.
Traverse the array.
If array elements are not equal.
Increment count by 1.
Decrement count by 1.
If flag is true and count is 0 , pr " Yes " . Otherwise " No ".
Driver Code.
Given arrays.
Size of the array"
Solution in Python:
 Write me a code to check if two arrays can be made equal by swapping pairs of one of the arrays and the other steps required?
assistant
#Here is code to check if two arrays can be made equal by swapping pairs of one of the arrays and the other steps required.
 def checkArrays ( arr1 , arr2 , N ) :
	count = 0
	flag = True
	for i in range ( N ) :
		if ( arr1 [ i ] != arr2 [ i ] ) :
			if ( arr1 [ i ] == 0 ) :
				count += 1
			else :
				count -= 1
				if ( count < 0 ) :
					flag = 0
					break
	if ( flag and count == 0 ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	arr1 = [ 0 , 0 , 1 , 1 ]
	arr2 = [ 1 , 1 , 0 , 0 ]
	N = len ( arr1 )
	checkArrays ( arr1 , arr2 , N )