Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created July 24, 2018 10:17
Show Gist options
  • Save luojiyin1987/c2fa338eaeb315c6379a3137f6bb1138 to your computer and use it in GitHub Desktop.
Save luojiyin1987/c2fa338eaeb315c6379a3137f6bb1138 to your computer and use it in GitHub Desktop.
Rotate String
func rotateString(A string, B string) bool {
if len(A) != len(B) {
return false
} else if (len(A) == 0 && len(B)==0) {
return true
}
bytes := []byte(A)
l := len(bytes)
for i:=0 ; i<l ; i++ {
bytes = append(bytes[1:], bytes[0])
if B == string(bytes) {
return true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment