Array Right Rotation Problem
Array Right Rotation Problem — ExecCode School DSA Practice
Solve the Array Right Rotation problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given two numbers, and then a list of items. Your task is to the first number tells you how many items are in the list. The second number tells you how many items to move from the back of the list to the front. Move that many items from the very end to the very beginning of the list, in the same order. Then, print the updated list.
Examples
Input 5 2 1 2 3 4 5; Output 4 5 1 2 3. Input 10 3 1 2 3 4 5 6 7 8 9 10; Output 8 9 10 1 2 3 4 5 6 7
Constraints
1 <= D <= N <= 10^5
Practice Array Right Rotation free on ExecCode. Browse DSA problems, topic map, and placement guides.