human
Smallest index that splits an array into two subarrays with equal product | Function to find the smallest index that splits the array into two subarrays with equal product.
Stores the product of the array.
Traverse the given array.
Stores the product of left and the right subarrays.
Traverse the given array.
Update the products.
Check if product is equal.
Print resultant index.
If no partition exists , then print - 1..
Driver Code"
Solution in Python:
assistant
#Here is code to smallest index that splits an array into two subarrays with equal product and the other steps required.
 def prodEquilibrium ( arr , N ) :
	product = 1
	for i in range ( N ) :
		product *= arr [ i ]
	left = 1
	right = product
	for i in range ( N ) :
		left = left * arr [ i ]
		right = right // arr [ i ]
		if ( left == right ) :
			print ( i + 1 )
			return
	print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 3 , 2 , 1 ]
	N = len ( arr )
	prodEquilibrium ( arr , N )