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
 
Example 2:
Input:
N = 8
A[] = {9, 8, 7, 6, 4, 2, 1, 3}
Output:
3 9 8 7 6 4 2 1
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function rotate() which takes the array A[] and its size N as inputs and modify the array in place.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1<=N<=10^{5}
0<=a[i]<=10^{5}

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



def rotate( arr, n):

    

    



Solutions:
def rotate(arr, n):
	a = arr.pop()
	arr.insert(0, a)


def rotate(arr, n):
	y = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = y
	return arr


def rotate(arr, n):
	temp = arr[-1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = temp


def rotate(arr, n):
	arr[:] = arr[-1:] + arr[:-1]


def rotate(arr, n):
	length = len(arr)
	arr[:] = arr[-1:length] + arr[0:-1]
	return arr


def rotate(arr, n):
	a = arr[n - 1]
	for i in range(n - 1, -1, -1):
		arr[i] = arr[i - 1]
	arr[0] = a
	return arr


def rotate(arr, n):
	res = arr[-1]
	arr.pop(-1)
	arr.insert(0, res)
	return arr


def rotate(arr, n):
	x = arr.pop()
	arr.insert(0, x)


def rotate(arr, n):
	return arr.insert(0, arr.pop())


def rotate(arr, n):
	last = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = last
	return arr


def rotate(arr, n):
	ele = arr[-1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = ele
	return arr


def rotate(arr, n):
	x = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = x


def rotate(arr, n):
	k = arr[n - 1]
	arr.insert(0, k)
	arr.pop()
	return arr


def rotate(arr, n):
	arr.insert(0, arr[-1])
	arr.pop()


def rotate(arr, n):
	for i in range(n - 1, 0, -1):
		t = arr[i]
		arr[i] = arr[i - 1]
		arr[i - 1] = t
	return arr


def rotate(arr, n):
	k = arr[n - 1]
	ptr = n - 1
	while ptr > 0:
		arr[ptr] = arr[ptr - 1]
		ptr = ptr - 1
	arr[ptr] = k
	return arr


def rotate(arr, n):
	o = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = o
	return arr


def rotate(arr, n):
	x = arr[n - 1]
	for i in range(n - 2, -1, -1):
		arr[i + 1] = arr[i]
	arr[0] = x
	return arr


def rotate(arr, n):
	x = arr[n - 1]
	i = n - 1
	while i > 0:
		arr[i] = arr[i - 1]
		i -= 1
	arr[0] = x
	return arr


def rotate(arr, n):
	last_val = arr[n - 1]
	arr.pop(-1)
	arr.insert(0, last_val)
	return arr


def rotate(arr, n):
	for i in range(n):
		(arr[0], arr[i]) = (arr[i], arr[0])


def rotate(arr, n):
	temp = arr.pop()
	arr.insert(0, temp)


def rotate(arr, n):
	pointer = 0
	while pointer < n:
		(arr[pointer], arr[n - 1]) = (arr[n - 1], arr[pointer])
		pointer += 1


def rotate(arr, n):
	temp = arr[n - 1]
	k = n
	while k > 0:
		arr[k - 1] = arr[k - 2]
		k = k - 1
	arr[0] = temp


def rotate(arr, n):
	temp = arr[n - 1]
	del arr[n - 1]
	arr.insert(0, temp)
	return arr


def rotate(arr, n):
	last = arr.pop()
	arr.insert(0, last)


def rotate(arr, n):
	s = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = s
	return arr


def rotate(arr, n):
	result = []
	result.append(arr[len(arr) - 1])
	for i in range(len(arr) - 1):
		result.append(arr[i])
	for j in range(len(result)):
		arr[j] = result[j]


def rotate(arr, n):
	a = arr.pop(len(arr) - 1)
	arr.insert(0, a)
	return arr


def rotate(arr, n):
	x = arr.pop(len(arr) - 1)
	arr.insert(0, x)
	return arr


def rotate(arr, n):
	last = arr[n - 1]
	arr.pop(n - 1)
	arr.insert(0, last)
	return arr


def rotate(arr, n):
	last_element = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = last_element


def reverse(arr, start, end):
	while start < end:
		temp = arr[start]
		arr[start] = arr[end]
		arr[end] = temp
		start += 1
		end -= 1

def rotate(arr, n):
	reverse(arr, 0, n - 1)
	reverse(arr, 1, n - 1)


def rotate(arr, n):
	end = arr[n - 1]
	arr.pop(n - 1)
	arr.insert(0, end)
	return arr


def rotate(arr, n):
	a = arr[-1]
	del arr[-1]
	arr.insert(0, a)
	return arr


def rotate(arr, n):
	lastele = arr[-1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = lastele
	return arr


def rotate(arr, n):
	li = []
	li.append(arr[-1])
	for i in range(n - 1):
		li.append(arr[i])
	return li


def rotate(arr, n):
	l = arr[n - 1]
	arr.pop()
	arr.insert(0, l)
	return arr


def rotate(arr, n):
	i = 0
	j = n - 1
	while i != j:
		(arr[i], arr[j]) = (arr[j], arr[i])
		i = i + 1


def rotate(array, n):
	array[:] = array[-1:] + array[:-1]
	return array


def rotate(arr, n):
	for i in range(0, len(arr) - 1):
		temp = arr[i]
		arr[i] = arr[len(arr) - 1]
		arr[len(arr) - 1] = temp
	return arr


def rotate(arr, n):
	t = arr[len(arr) - 1]
	arr.pop(len(arr) - 1)
	arr.insert(0, t)
	return arr


def rotate(arr, n):
	ax = []
	ax.append(0)
	temp = arr[0]
	ax[0] = arr[n - 1]
	for i in range(0, n - 1):
		ax.append(arr[i])
	for i in range(0, n):
		arr[i] = ax[i]
	return arr


def rotate(arr, n):
	k = arr[-1]
	del arr[-1]
	arr.insert(0, k)


def rotate(arr, n):
	a = arr[-1]
	i = n - 1
	while i >= 0:
		arr[i] = arr[i - 1]
		i -= 1
	arr[0] = a
	return arr


def rev(arr, l, r):
	while l < r:
		(arr[l], arr[r]) = (arr[r], arr[l])
		l += 1
		r -= 1

def rotate(arr, n):
	i = n - 1
	temp = arr[n - 1]
	while i > 0:
		arr[i] = arr[i - 1]
		i -= 1
	arr[i] = temp


def rotate(arr, n):
	arr[:] = arr[-1:] + arr[0:-1]
	return arr


def rotate(arr, n):
	first = arr[n - 1]
	arr.pop(n - 1)
	arr.insert(0, first)
	return arr


def rotate(arr, n):
	if n < 2:
		return arr
	temp = arr[-1]
	for i in range(0, n):
		temp2 = arr[i]
		arr[i] = temp
		temp = temp2
	return arr


def rotate(arr, n):
	k = 1
	for i in range(k):
		arr.insert(0, arr.pop(-1))
	return arr


def rotate(arr, n):

	def reverse(arr, l, r):
		while l < r:
			tmp = arr[l]
			arr[l] = arr[r]
			arr[r] = tmp
			l += 1
			r -= 1
	reverse(arr, 0, n - 1)
	reverse(arr, 1, n - 1)


def rotate(arr, n):
	temp = arr[n - 1]
	arr.pop(n - 1)
	arr.insert(0, temp)
	return arr


def rotate(arr, n):
	(l, r) = (0, len(arr) - 1)
	while l < r:
		(arr[l], arr[r]) = (arr[r], arr[l])
		l = l + 1
		r = r - 1
	(l, r) = (1, len(arr) - 1)
	while l < r:
		(arr[l], arr[r]) = (arr[r], arr[l])
		l = l + 1
		r = r - 1