human
Smallest element in an array that is repeated exactly ' k ' times . | finds the smallest number in arr [ ] that is repeated k times.
Sort the array.
Find the first element with exactly k occurrences ..
Driver code"
How can the above be solved in Python?
 Write me a code to smallest element in an array that is repeated exactly ' k ' times?
assistant
#Here is code to smallest element in an array that is repeated exactly ' k ' times .
 def findDuplicate ( arr , n , k ) :
	arr . sort ( )
	i = 0
	while ( i < n ) :
		j , count = i + 1 , 1
		while ( j < n and arr [ j ] == arr [ i ] ) :
			count += 1
			j += 1
		if ( count == k ) :
			return arr [ i ]
		i = j
	return - 1
arr = [ 2 , 2 , 1 , 3 , 1 ] ;
k = 2
n = len ( arr )
print findDuplicate ( arr , n , k )