From dbcd875d3bcc0ccbf6b331bbfd07e799e272688b Mon Sep 17 00:00:00 2001 From: Yuhao Ju Date: Mon, 27 Mar 2023 16:22:07 +0800 Subject: [PATCH] =?UTF-8?q?update=200459.=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E5=AD=90=E5=AD=97=E7=AC=A6=E4=B8=B2=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=8D=E6=9D=82=E5=BA=A6=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0459.重复的子字符串.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/problems/0459.重复的子字符串.md b/problems/0459.重复的子字符串.md index 5d870219..98c02a25 100644 --- a/problems/0459.重复的子字符串.md +++ b/problems/0459.重复的子字符串.md @@ -73,6 +73,8 @@ public: } }; ``` +* 时间复杂度: O(n) +* 空间复杂度: O(1) 不过这种解法还有一个问题,就是 我们最终还是要判断 一个字符串(s + s)是否出现过 s 的过程,大家可能直接用contains,find 之类的库函数。 却忽略了实现这些函数的时间复杂度(暴力解法是m * n,一般库函数实现为 O(m + n))。 @@ -185,6 +187,8 @@ public: } }; ``` +* 时间复杂度: O(n) +* 空间复杂度: O(n) 前缀表(不减一)的C++代码实现: @@ -219,6 +223,8 @@ public: } }; ``` +* 时间复杂度: O(n) +* 空间复杂度: O(n) ## 其他语言版本