#C13770. Rotate List Left
Rotate List Left
Rotate List Left
You are given a list of integers and an integer n. Your task is to rotate the list to the left by n positions. The rotation should be performed using modulo arithmetic so that if n is greater than the length of the list (or negative), the list is rotated accordingly.
For example, rotating the list [1, 2, 3, 4, 5] by 2 positions yields [3, 4, 5, 1, 2]. Similarly, rotating the list by a negative number, such as -2, effectively rotates it to the right by 2 positions, yielding [4, 5, 1, 2, 3].
If the list is empty, simply output an empty line.
inputFormat
The input is provided via standard input (stdin) and consists of two lines:
- The first line contains the elements of the list separated by spaces. An empty line represents an empty list.
- The second line contains an integer n indicating the number of positions by which the list should be rotated to the left.
outputFormat
The output should be printed to standard output (stdout) as a single line containing the rotated list. The elements should be separated by a single space. If the list is empty, output nothing.
## sample1 2 3 4 5
2
3 4 5 1 2