ProblemWrite a function to rotate given array clock-wise. i.e. Rotate(int a, int k)
1. One obvious approach is by using extra memory of 'k', and then rotating the array - it is O(N) and O(k) space.
2. Rotating array by '1' and repeating the task for 'k' number of times
Below is the approach of achieving the result in O(N) and O(1) space:
a. Firstly, reverse the array
b. And then reverse first 'k' elements and reverse remaining elements separately.