In Collection class rotate function takes two parameters - the name of array and the position by which it should be rotated The below function will be rotating the array left in linear time Collections . rotate ( ) rotate the array from right hence n - k
Collections . rotate ( Arrays . asList ( arr ) , n - k ) ;