Solution 3. O(n) runtime, O(1) space, using reverse algorithm 1. decide on the split point depending if it is a left or right rotation. 2. reverse the splitted array separately, then reverse the whole array. 1p
Consider an integer array of sizen. The task at hand is to rotate the elements clockwise by one element, i.e., place the last elements at the start of the array by pushing the remaining elements to the end. Example Input: array[]= {1, 2, 3, 4, 5} Output: array[] = {5, 1...