#K73142. Array Left Rotation
Array Left Rotation
Array Left Rotation
Given an array of integers and an integer k, perform a left rotation on the array by moving the first k elements to the end of the array.
If the array is denoted as \(A\) with length \(n\), the resulting array after a left rotation of \(k\) positions can be expressed by:
\(A_{rotated} = A[k \% n : ] \;\Vert\; A[0 : k \% n]\)
Note that when \(k \geq n\), use \(k \mod n\) as the effective number of rotations.
inputFormat
The input is given via standard input in the following format:
n k a1 a2 ... an
Where:
- n is the number of elements in the array.
- k is the number of elements to rotate from the beginning of the array to the end.
- a1, a2, ..., an are the array elements.
outputFormat
Output the rotated array as a line of space-separated integers to standard output.
## sample5 2
1 2 3 4 5
3 4 5 1 2