Rotate Array Left by K Positions
M · mediumPracticearrays
Problem
Given an array of N elements, rotate it to the left by K positions.
Example
Input
5 2 1 2 3 4 5
Output
3 4 5 1 2
Reverse method: reverse first K, reverse last N-K, reverse whole array.