human
Number of pairs in an array having sum equal to product | Function to return the count of the required pairs.
Find the count of 0 s and 2 s in the array.
Find the count of required pairs.
Return the count.
Driver code"
How can the above be solved in Python?
 Write me a code to number of pairs in an array having sum equal to product and the other steps required?
assistant
#Here is code to number of pairs in an array having sum equal to product and the other steps required.
 def sumEqualProduct ( a , n ) :
	zero = 0
	two = 0
	for i in range ( n ) :
		if a [ i ] == 0 :
			zero += 1
		if a [ i ] == 2 :
			two += 1
	cnt = ( zero * ( zero - 1 ) ) // 2 + ( two * ( two - 1 ) ) // 2
	return cnt
a = [ 2 , 2 , 3 , 4 , 2 , 6 ]
n = len ( a )
print ( sumEqualProduct ( a , n ) )