All tasks
Mediumarrays

Rotate Array Left

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

The first line contains n and k, the second line contains n integers. Rotate the array k positions to the left cyclically and print the result on one line separated by spaces. k may exceed the array length.

Examples

Example 1
Input
5 2
1 2 3 4 5
Output
3 4 5 1 2
Example 2
Input
4 0
1 2 3 4
Output
1 2 3 4

Constraints

  • 1 ≤ n ≤ 10^5
  • 0 ≤ k ≤ 10^9
  • -10^9 ≤ a_i ≤ 10^9
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.