Merge pull request #2558 from markwang1992/459-repeatedSubstringPattern

459.重复的子字符串增加Go移动匹配解法
This commit is contained in:
程序员Carl 2024-06-12 11:08:53 +08:00 committed by GitHub
commit 2c40c6a29c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 0 deletions

View File

@ -403,6 +403,18 @@ func repeatedSubstringPattern(s string) bool {
} }
``` ```
移动匹配
```go
func repeatedSubstringPattern(s string) bool {
if len(s) == 0 {
return false
}
t := s + s
return strings.Contains(t[1:len(t)-1], s)
}
```
### JavaScript: ### JavaScript:
> 前缀表统一减一 > 前缀表统一减一