From 96359371d8668d1648cce37b2cfe3614fd01a49b Mon Sep 17 00:00:00 2001 From: markwang Date: Wed, 15 May 2024 10:52:59 +0800 Subject: [PATCH] =?UTF-8?q?459.=E9=87=8D=E5=A4=8D=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=A2=9E=E5=8A=A0Go=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=8C=B9=E9=85=8D=E8=A7=A3=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0459.重复的子字符串.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/problems/0459.重复的子字符串.md b/problems/0459.重复的子字符串.md index 1028bf1e..51425796 100644 --- a/problems/0459.重复的子字符串.md +++ b/problems/0459.重复的子字符串.md @@ -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: > 前缀表统一减一