Skip to content

Instantly share code, notes, and snippets.

@abdulrahmanAlotaibi
Created December 15, 2022 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulrahmanAlotaibi/cfc740f8d325d0cbdba2274b8394c22d to your computer and use it in GitHub Desktop.
Save abdulrahmanAlotaibi/cfc740f8d325d0cbdba2274b8394c22d to your computer and use it in GitHub Desktop.
Array # 6 : Rotate Array
func rotate(nums []int, k int) {
l := len(nums)
k = k % l
newNums := append(nums[l-k:l], nums[0:l-k]...)
copy(nums,newNums)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment