human
Check if any subarray of length M repeats at least K times consecutively or not | Function to check if any subarray of length M repeats at least K times consecutively or not.
Stores the required count of repeated subarrays.
Check if the next continuous subarray has equal elements.
Check if K continuous subarray of length M are found or not.
If no subarrays are found.
Driver Code"
How can the above be solved in Python?
 Can you provide a code to check if any subarray of length M repeats at least K times consecutively or not and the other steps required?
assistant
#Here is code to check if any subarray of length M repeats at least K times consecutively or not and the other steps required.
 def checkExists ( arr , N , M , K ) :
	count = 0
	for i in range ( N - M ) :
		if ( arr [ i ] == arr [ i + M ] ) :
			count += 1
		else :
			count = 0
		if ( count == M * ( K - 1 ) ) :
			return True
	return False
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 1 , 2 , 1 , 1 , 1 , 3 ]
	N = len ( arr )
	M = 2
	K = 2
	if ( checkExists ( arr , N , M , K ) ) :
		print ( " Yes " )
	else :
		print ( " No " )