Dsa
Arrays
Warm-up
Array Element Shifter
You are given an array of integers and a positive integer 'k'. Your task is to shift all the elements of the array to the right by 'k' positions. Elements that are shifted out from the end should appear at the beginning of the array. The value of 'k' may be greater than the length of the array.
Input format:
- The first line contains space-separated integers, the second line contains a single integer 'k'.
Output format:
- The modified array in the same space-separated format.
Example:
Input:
1 2 3 4 5
2
Output:
4 5 1 2 3
Key concepts
arraysmanipulationshifting
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