[Solved] What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?

What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?

a) 2, 1, 3, 4, 5
b) 3, 4, 5, 1, 2
c) 4, 5, 1, 2, 3
d) 1, 2, 3, 5, 4

Answer: b
Explanation: When the given array is rotated by 2 then the resulting array will be
Rotation 1: {2,3,4,5,1}
Rotation 2: {3,4,5,1,2}.
Thus, the final array is {3,4,5,1,2}.

Comments