https://leetcode.com/problems/rotate-string/
Rotate String - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
package main
import "strings"
func main() {
s := "abcde"
goal := "cdeab"
rotateString(s, goal)
}
//제출 코드
func rotateString(s string, goal string) bool {
if len(s) != len(goal) {
return false
} else {
s = s + s
// abcdeabcde
if strings.Contains(s, goal) {
return true
} else {
return false
}
}
}
'Algorithm > Go' 카테고리의 다른 글
[LeetCode] Merge Two Sorted Lists (0) | 2021.12.26 |
---|---|
[LeetCode] Contains Duplicate (0) | 2021.12.26 |
[Leetcode] Single Number (0) | 2021.12.20 |
[Leetcode] Majority Element (0) | 2021.12.19 |
[Leetcode] Maximum Number of Words You Can Type (0) | 2021.12.12 |