human
What is a code to print left rotation of array in O ( n ) time and O ( 1 ) space and the other steps required given the following:
Print left rotation of array in O ( n ) time and O ( 1 ) space | Function to leftRotate array multiple times.
To get the starting point of rotated array.
Prints the rotated array from start position.
Driver code.
Function Call.
Function Call.
Function Call"
Solution in Python:
assistant
#Here is code to print left rotation of array in O ( n ) time and O ( 1 ) space and the other steps required.
 def leftRotate ( arr , n , k ) :
	mod = k % n
	s = " "
	for i in range ( n ) :
		print str ( arr [ ( mod + i ) % n ] ) ,
	print
	return
arr = [ 1 , 3 , 5 , 7 , 9 ]
n = len ( arr )
k = 2
leftRotate ( arr , n , k )
k = 3
leftRotate ( arr , n , k )
k = 4
leftRotate ( arr , n , k )