Rotate Array by K Steps

00:00
EasyArrayTwo PointersMath
MicrosoftAmazon

Rotate integer array to the right by k steps. k may be larger than array length.

Examples

Input → [1,2,3,4,5,6,7], k=3
Output → [5,6,7,1,2,3,4]
Input → [-1,-100,3,99], k=2
Output → [3,99,-1,-100]
Input → [1,2], k=3
Output → [2,1]
Note: k%2=1