#C14271. Left Rotation of an Array
Left Rotation of an Array
Left Rotation of an Array
You are given an array of integers and a number of left rotations to perform. A left rotation on an array shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on the array a = [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2].
The task is to perform \(r\) left rotations on the array. If \(r\) is greater than the length of the array, you must use \(r \mod n\) rotations, where \(n\) is the number of elements in the array.
Note that if the array is empty, the output should also be empty.
inputFormat
The input is read from stdin and has the following format:
- The first line contains two integers \(n\) and \(r\), where \(n\) is the number of elements in the array and \(r\) is the number of left rotations.
- The second line contains \(n\) space-separated integers representing the elements of the array. If \(n = 0\), the second line will be empty.
outputFormat
Output to stdout the resulting array after performing the left rotations. The elements should be printed in order and separated by a single space. If the resulting array is empty, output an empty line.
## sample5 0
1 2 3 4 5
1 2 3 4 5