72. Rotate the Playlist

Acceptance — 0 accepted 0 submissions

Easy
Arrays
No companies listed
Your music app plays songs in a circle. When you press 'skip' k times, the first k songs move to the end of the playlist.

Rotate the array to the left by k positions.

Input Format
The first line has n and k.
The second line has n integers.

Output Format
Print the rotated array, separated by single spaces.

Constraints
• 1 ≤ n ≤ 1000
• 0 ≤ k ≤ 10^9
• -1000 ≤ value ≤ 1000

Example 1

Input
5 2
1 2 3 4 5
Output
3 4 5 1 2

Explanation Songs 1 and 2 move to the end.

Example 2

Input
3 3
7 8 9
Output
7 8 9

Explanation Rotating by 3 = full circle, nothing changes.

Example 3

Input
4 0
4 3 2 1
Output
4 3 2 1

Explanation No skip at all.

Example 4

Input
3 1000000000
10 20 30
Output
20 30 10

Explanation 10^9 % 3 = 1, so rotate by just 1.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
3 4 5 1 2
No results yet
Run your code to test it against the sample cases.
Problem List