#K34857. Left Rotation of an Array
Left Rotation of an Array
Left Rotation of an Array
You are given an array of n integers and an integer d representing the number of left rotations to perform on the array. A left rotation operation on an array shifts each of the array's elements 1 unit to the left. After performing a left rotation, the first element moves to the end of the array.
More formally, if we denote the original array as \(a_0, a_1, \ldots, a_{n-1}\), then after one left rotation the array becomes \(a_1, a_2, \ldots, a_{n-1}, a_0\). After \(d\) left rotations, the element at index \(i\) will move to index \((i - d + n) \bmod n\). Note that if \(d \ge n\), only the remainder \(d \bmod n\) affects the final outcome.
inputFormat
The first line contains two space-separated integers: n (the number of elements in the array) and d (the number of left rotations to perform). The second line contains n space-separated integers representing the elements of the array.
outputFormat
Print the array after performing left rotations. The output should be a single line of space-separated integers.## sample
5 2
1 2 3 4 5
3 4 5 1 2