Leetcode Note: Go - Rotate String
Rotate String - LeetCode
https://leetcode.com/problems/rotate-string/
- Go 言語で取り組んだメモ
所感
- string 変数 s, goal が渡されるので s を rotate した結果として goal を算出できるのであれば true を return する
回答
Rotate String - LeetCode
https://leetcode.com/problems/rotate-string/solution/
[Golang] 796. just repeat string twice | One Line solution - LeetCode Discuss
https://leetcode.com/problems/rotate-string/discuss/1645328/Golang-796.-just-repeat-string-twice-or-One-Line-solution
func rotateString(s string, goal string) bool {
return len(s) == len(goal) && strings.Contains(strings.Repeat(s, 2), goal)
}