Rotate example
Input
rotate_right([1, 2, 3, 4, 5], 2)
Output
[4, 5, 1, 2, 3]
Array rotated right by 2 positions.
Full lesson preview
Rotate the elements of an array to the right by k steps, in-place.
Problem statement
Task
Examples
Input
rotate_right([1, 2, 3, 4, 5], 2)
Output
[4, 5, 1, 2, 3]
Array rotated right by 2 positions.
Input format
Output format
Constraints
Samples
Input
rotate_right([1, 2, 3], 3)
Output
[1, 2, 3]
k equal to array length results in the same array.