human
Smallest subarray which upon repetition gives the original array | Function to print the array.
Function to find the smallest subarray.
Corner Case.
Initialize the auxiliary subarray.
Push the first 2 elements into the subarray brr [ ].
Iterate over the length of subarray.
If array can be divided into subarray of i equal length.
Check if on repeating the current subarray gives the original array or not.
Subarray found.
Add current element into subarray.
No subarray found.
Driver Code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to smallest subarray which upon repetition gives the original array and the other steps required.
 def printArray ( brr ) :
	for it in brr :
		print ( it , end = ' ▁ ' )
def RepeatingSubarray ( arr , N ) :
	if ( N < 2 ) :
		print ( " - 1" )
	brr = [ ]
	brr . append ( arr [ 0 ] )
	brr . append ( arr [ 1 ] )
	for i in range ( 2 , N // 2 + 1 ) :
		if ( N % i == 0 ) :
			a = False
			n = len ( brr )
			j = i
			while ( j < N ) :
				K = j % i
				if ( arr [ j ] == brr [ K ] ) :
					j += 1
				else :
					a = True
					break
			if ( not a and j == N ) :
				printArray ( brr )
				return
		brr . append ( arr [ i ] )
	print ( " - 1" )
	return
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 2 , 1 , 2 , 2 , 1 , 2 , 2 ]
	N = len ( arr )
	RepeatingSubarray ( arr , N )