
LEFT ROTATE
|
All submissions for this problem are available.
A left rotation operation on an array of size N shifts each of the array's elements 1 unit to the left. For example, if 3 left rotations are performed on array [1,2,3,4,5], then the array would become [4,5,1,2,3]. Given an array of integers N and a number D , perform D left rotations on the array. Then print the updated array as a single line of space-separated integers.
Input
- The first line contains a single integer N denoting the number of elements in the array.
- The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.
- The third line contains a single integer D denoting the number of rotation to perform on the array.
Output
- Print a single line of N space-separated integers denoting the final state of the array after performing D left rotations.
Constraints
- 1 ≤ N ≤ 105
- 1 ≤ D ≤ N
- 1 ≤ Ai ≤ 106
Example
Input 1: 5 1 2 3 4 5 4 Output 1: 5 1 2 3 4
Explanation
When we perform D = 4left rotations, the array undergoes the following sequence of changes:
[1,2,3,4,5] → [2,3,4,5,1] → [3,4,5,1,2] → [4,5,1,2,3] → [5,1,2,3,4]
Thus, we print the array's final state as a single line of space-separated values, which is 5 1 2 3 4
Author: | araj5ak |
Tags | araj5ak |
Date Added: | 20-02-2018 |
Time Limit: | 1 sec |
Source Limit: | 50000 Bytes |
Languages: | C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS |
Comments
- Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
