Given an array, rotate the array by one position in clock-wise direction.
Example 1:
Input:
N = 5
A[] = {1, 2, 3, 4, 5}
Output:
5 1 2 3 4
solution
last=arr[n-1]
for i in range(n-2,-1,-1):
arr[i+1]=arr[i]
arr[0]=last
Given an array, rotate the array by one position in clock-wise direction.
Example 1:
Input:
N = 5
A[] = {1, 2, 3, 4, 5}
Output:
5 1 2 3 4
solution
last=arr[n-1]
for i in range(n-2,-1,-1):
arr[i+1]=arr[i]
arr[0]=last
0Comments
Put Your Thought or Query Here