Created
July 24, 2018 10:17
-
-
Save luojiyin1987/c2fa338eaeb315c6379a3137f6bb1138 to your computer and use it in GitHub Desktop.
Rotate String
This file contains hidden or 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
| 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