human
Write me a code to find the first repeating element in an array of integers and the other steps required given the following:
Find the first repeating element in an array of integers | This function prints the first repeating element in arr [ ].
Initialize index of first repeating element.
Creates an empty hashset.
Traverse the input array from right to left.
If element is already in hash set , update Min.
Else add element to hash set.
Print the result.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to find the first repeating element in an array of integers and the other steps required.
 def printFirstRepeating ( arr , n ) :
	Min = - 1
	myset = dict ( )
	for i in range ( n - 1 , - 1 , - 1 ) :
		if arr [ i ] in myset . keys ( ) :
			Min = i
		else :
			myset [ arr [ i ] ] = 1
	if ( Min != - 1 ) :
		print ( " The ▁ first ▁ repeating ▁ element ▁ is " , arr [ Min ] )
	else :
		print ( " There ▁ are ▁ no ▁ repeating ▁ elements " )
arr = [ 10 , 5 , 3 , 4 , 3 , 5 , 6 ]
n = len ( arr )
printFirstRepeating ( arr , n )