instagram

Circular Array Rotation

Right circular rotation on an array of integers [1,2,...,n-1,n]. After performing one right circular rotation operation, the array is transformed from [1,2,...,n-1,n] to [n,1,2,...,n-1].

Perform rotation k number of times and find out element in particular position.

Inputs :

Line One : Size of array, Number of rotation, Number of positions going to print.
Line Two : Array of integers.
Next lines will be positions to find after rotations.

Sample :

Inputs :

3 2 3
1 2 3
0
1
2

Output :
2
3
1

Here Array is [1 2 3], We are going to rotate it two times.

Rotation One : [3 1 2]
Rotation Two : [2 3 1]

Now Positions
0 is 2
1 is 3
2 is 1

Algorithm :

Share