mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
update 0459.重复的子字符串:添加复杂度分析
This commit is contained in:
@ -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)
|
||||
|
||||
|
||||
## 其他语言版本
|
||||
|
Reference in New Issue
Block a user