SDE Path

Left Rotate Array by K Places

Medium

Left Rotate Array by K Places

Rotate an array to the left by K positions using O(1) extra space.

Input format

The first line contains N and K. The second line contains N space-separated integers.

Output format

Print the resulting array as space-separated integers on one line. K may exceed N.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
5 2
1 2 3 4 5
Expected output
3 4 5 1 2
Example 2
Input
4 7
10 20 30 40
Expected output
40 10 20 30