Practice Problems
0% completed
First index of element
Last index of element
Reverse the array
Rotate array
Find the kth largest and smallest element in an array
Sort an array containing 0,1 and 2 24

# Rotate array

Difficulty: EASY

Problem Statement
Suggest Edit

#### Input Format:

``````The first line contains an integer N representing the size of the array.

The second line contains N space-separated integers representing the elements of the array.

The last line contains an integer K representing the number of times the array has to be rotated in the left direction.
``````

#### Output Format:

``````The only line of the output prints N space-separated integers representing the Rotated array elements.
``````
##### Constraints:
``````1 <= N <= 10^3
1 <= arr[i] <= 10^9
1 <= K < N
``````
##### Sample Input:
``````8
7 5 2 11 2 43 1 1
2
``````
##### Sample Output:
``````2 11 2 43 1 1 7 5
``````
##### Explanation of Sample Input:
``````Rotate 1 steps to the left: 5 2 11 2 43 1 1 7
Rotate 2 steps to the left: 2 11 2 43 1 1 7 5
``````   Console