Rotate array by K steps
Last updated
Last updated
For an array of sized instead of doing rotation
we can simply do rotation
If we rotate steps to right we need to start reading the rotated array from the last elements.
If we rotate steps to left we need to start reading the rotated array after skipping elements from start
We iterate the whole array only once
No extra space is needed
Time complexity :
Space complexity :