Dsa
Arrays
Hard
Circular Array Rotation
You are given an array and a number of rotations you have to perform on the array. The rotation operation means moving the last element of the array to the front. Write a program to perform the given number of rotations and print the final array.
Input format:
- The first line contains two integers n (1 ≤ n ≤ 10^5) and k (0 ≤ k ≤ 10^9).
- The second line contains n space-separated integers a[i] (0 ≤ a[i] ≤ 10^9).
Output format:
- A single line of space-separated integers representing the final array.
Example:
Input:
5 2
1 2 3 4 5
Output:
4 5 1 2 3
Key concepts
arraysrotationmodulus
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now