Skip to content

Instantly share code, notes, and snippets.

@tommymcguiver
Created October 12, 2018 03:25
Show Gist options
  • Save tommymcguiver/95d8a854b1ac0313d6df44674d1e9bb0 to your computer and use it in GitHub Desktop.
Save tommymcguiver/95d8a854b1ac0313d6df44674d1e9bb0 to your computer and use it in GitHub Desktop.
Rotate Left
package main
import (
"fmt"
)
func rotateLeft(a []int, times int) []int {
for x := 0; x < times; x++ {
a = append(a[1:], a[:1]...)
}
return a
}
func main() {
fmt.Println(rotateLeft([]int{1, 5, 8, 15, 16, 22}, 3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment