human
Longest subarray with elements having equal modulo K | function to find longest sub - array whose elements gives same remainder when divided with K.
Iterate in the array.
check if array element greater then X or not.
Driver code"
How can the above be solved in Python?
 Can you provide a code to longest subarray with elements having equal modulo K and the other steps required?
assistant
#Here is code to longest subarray with elements having equal modulo K and the other steps required.
 def LongestSubarray ( arr , n , k ) :
	count = 1
	max_lenght = 1
	prev_mod = arr [ 0 ] % k
	for i in range ( 1 , n ) :
		curr_mod = arr [ i ] % k
		if curr_mod == prev_mod :
			count += 1
		else :
			max_lenght = max ( max_lenght , count )
			count = 1
			prev_mod = curr_mod
	return max ( max_lenght , count )
arr = [ 4 , 9 , 7 , 18 , 29 , 11 ]
n = len ( arr )
k = 11
print ( LongestSubarray ( arr , n , k ) )