Created
October 12, 2018 03:25
-
-
Save tommymcguiver/95d8a854b1ac0313d6df44674d1e9bb0 to your computer and use it in GitHub Desktop.
Rotate Left
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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