Answers for "cyclically rotate an array by one"

1

cyclically rotate an array by one

def rotate( arr, n):
    a[0],a[1:]=a[-1],a[:n-1]
    
#Driver Code    
a=[-1,2,3,7,5]
rotate(a,len(a))
print(a)
#Output: [5, -1, 2, 3, 7]
Posted by: Guest on September-10-2021

Code answers related to "cyclically rotate an array by one"

Python Answers by Framework

Browse Popular Code Answers by Language