223. Rotate the Carousel

Easy · Array

A carousel rotates items left or right. Given an array and a number `k`, rotate the array to the right by `k` positions. (Items that fall off the right reappear on the left.)

Examples

Example 1
Input: arr=[1,2,3,4,5], k=2
Output: [4,5,1,2,3]
Explanation: Last 2 moved to front

Constraints