Write a program to rotate elements of given array to right by K positions.
Input (int[], int) |
Output (int[]) |
{1, 2, 3, 4, 5, 6, 7, 8}, 2 |
{7, 8, 1, 2, 3, 4, 5, 6} |
{1, 2, 3, 4, 5, 6, 7, 8}, 5 |
{4, 5, 6, 7, 8, 1, 2, 3} |
{20, 6, 8, 11, 30}, 3 |
{8, 11, 30, 20, 6} |
{12, 15, 19, 1, 33}, 1 |
{33, 12, 15, 19, 1} |
{5, 6, 7, 8, 9, 10}, -2 |
{5, 6, 7, 8, 9, 10} |
{4, 6, 5, 7, 1}, 11 |
{1, 4, 6, 5, 7} |