+ 1

Help

A user gives you an array of n integers and an integer k. You need to shift the array & wrap around k times as shown in the input examples below. Input  8  1 2 3 4 5 6 7 8  3 Output  6 7 8 1 2 3 4 5

22nd May 2018, 7:23 PM
eerv
eerv - avatar
1 Answer
0
there is a good fact here that the maximum number of shifts you can do is the size of the array (8 in this case) after that you are repeating the same iteration so you can start by get k mod n and in this case you will shift by the result you can use queue as a container to implement this problem
23rd May 2018, 1:29 PM
Shahd Moemen
Shahd Moemen - avatar