Given an array of integers, rotate it one position.
Anonymous
1-divide the array in 2 of rotation order (e.g. num rotation =3 , then a1[N-3] , a2[3-N] 2-Reverse the first array 3-reverse the second array 3-reverse the whole array Note that the functions that do the reverse is not creating new arrays. Then with this you have time complexity O(n) and space complexity O(1) because you're using only one array in memory
Check out your Company Bowl for anonymous work chats.