dsa · medium

Rotate List

GreyOrangeLinked List

Rotate value-list head to the **right** by k. Return the values.

Arguments

**Example:** [1,2,3,4,5], k=2[4,5,1,2,3].

Constraints

0 <= length <= 500 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[1,2,3,4,5]
2

Expected:
[4,5,1,2,3]

Example 2

Input:
[0,1,2]
4

Expected:
[2,0,1]

Open in the Dojo editor