Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9635937

Browse files
459.重复的子字符串增加Go移动匹配解法
1 parent 14ff932 commit 9635937

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎problems/0459.重复的子字符串.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,18 @@ func repeatedSubstringPattern(s string) bool {
403403
}
404404
```
405405

406+
移动匹配
407+
408+
```go
409+
func repeatedSubstringPattern(s string) bool {
410+
if len(s) == 0 {
411+
return false
412+
}
413+
t := s + s
414+
return strings.Contains(t[1:len(t)-1], s)
415+
}
416+
```
417+
406418
### JavaScript:
407419

408420
> 前缀表统一减一

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /