Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save govindsharma7/1403f35b73f14666624accd10fc5ba08 to your computer and use it in GitHub Desktop.
Save govindsharma7/1403f35b73f14666624accd10fc5ba08 to your computer and use it in GitHub Desktop.
# -> (i + k) % len(nums)
# A -> List
# k -> number of postion
def rotate(A, k):
k %= len(A)
A[k:], A[:k] = A[:-k], A[-k:]
return A
print(rotate([4, 5, 1, 2, 3], 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment