Array Left Rotation Problem

Array Left Rotation Problem — ExecCode School DSA Practice

Solve the Array Left 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 front of the list to the back. Move that many items from the very beginning to the very end of the list, in the same order. Then, print the updated list.

Examples

Input 5 2 1 2 3 4 5; Output 3 4 5 1 2. Input 10 3 1 2 3 4 5 6 7 8 9 10; Output 4 5 6 7 8 9 10 1 2 3

Constraints

1 <= D <= N <= 10^5

Practice Array Left Rotation free on ExecCode. Browse DSA problems, topic map, and placement guides.