Rotate Array - Coding Ninjas
Rotate Array - Coding Ninjas
Rotate array
Easy 0/40 Average time to solve is 25m
Given an array 'arr' with 'n' elements, the task is to rotate the array to the left by 'k' steps, where 'k'
is non-negative.
Example:
Sample Input 1:
8
7 5 2 11 2 43 1 1
2
Sample Output 1:
2 11 2 43 1 1 7 5
Sample Input 2:
4
5678
3
Sample Output 2:
8567
O(n), where ‘n’ is the size of the array ‘arr’ and ‘k’ is the number of rotations.
Constraints: