Quickly find multiple left rotations of an array | Set 1 | Function to left rotate an array k times ; Print rray after k rotations ; Driver Code
function leftRotate ( arr , n , k ) { for ( let i = k ; i < k + n ; i ++ ) document . write ( arr [ i % n ] + " " ) ; } let arr = [ 1 , 3 , 5 , 7 , 9 ] ; n = arr . length ; k = 2 ; leftRotate ( arr , n , k ) ; document . write ( " " ) ; k = 3 ; leftRotate ( arr , n , k ) ; document . write ( " " ) ; k = 4 ; leftRotate ( arr , n , k ) ; document . write ( " " ) ;