human
Can you provide a code to pair with given product and the other steps required given the following:
Pair with given product | Set 1 ( Find if any pair exists ) | Returns true if there is a pair in arr [ 0. . n - 1 ] with product equal to x ..
Create an empty set and insert first element into it.
Traverse remaining elements.
0 case must be handles explicitly as x % 0 is undefined behaviour in C ++.
x / arr [ i ] exists in hash , then we found a pair.
Insert arr [ i ].
Driver code"
Solution in Python:
assistant
#Here is code to pair with given product and the other steps required.
 def isProduct ( arr , n , x ) :
	if n < 2 :
		return False
	s = set ( )
	for i in range ( 0 , n ) :
		if arr [ i ] == 0 :
			if x == 0 :
				return True
			else :
				continue
		if x % arr [ i ] == 0 :
			if x // arr [ i ] in s :
				return True
			s . add ( arr [ i ] )
	return False
if __name__ == " _ _ main _ _ " :
	arr = [ 10 , 20 , 9 , 40 ]
	x = 400
	n = len ( arr )
	if isProduct ( arr , n , x ) :
		print ( " Yes " )
	else :
		print ( " No " )
	x = 190
	if isProduct ( arr , n , x ) :
		print ( " Yes " )
	else :
		print ( " No " )