#C1355. Rotate Array to the Left
Rotate Array to the Left
Rotate Array to the Left
You are given an integer d
and an array arr
of n
integers. Your task is to rotate the array to the left d
times. That is, the first d
elements of the array will move to the end in the same order.
For example, if arr = [1, 2, 3, 4, 5]
and d = 4
, the rotated array will be [5, 1, 2, 3, 4]
. Use LaTeX format for any formulas needed. One can express the rotation operation mathematically as:
Write a program that reads from stdin
and outputs the rotated array to stdout
with numbers separated by a single space.
inputFormat
The first line contains two space-separated integers n
and d
, where n
is the number of elements in the array, and d
is the number of left rotations. The second line contains n
space-separated integers representing the elements of the array.
outputFormat
Output a single line containing the rotated array as space-separated integers.
## sample5 2
1 2 3 4 5
3 4 5 1 2