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
function leftRotate ( arr , n , k ) { let mod = k % n ; for ( let i = 0 ; i < n ; i ++ ) document . write ( ( arr [ ( mod + i ) % n ] ) + " " ) ; document . write ( " " ) ; } let arr = [ 1 , 3 , 5 , 7 , 9 ] ; let n = arr . length ; let k = 2 ; leftRotate ( arr , n , k ) ; document . write ( " " ) ; k = 3 ; leftRotate ( arr , n , k ) ; document . write ( " " ) ; k = 4 ; leftRotate ( arr , n , k ) ;