mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新代码块
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
但是在解释的过程中有不恰当的地方,所以来专门写一篇文章来详细说一说这个问题。
|
||||
|
||||
使用vector的代码如下:
|
||||
```C++
|
||||
```CPP
|
||||
// 版本一,使用vector(动态数组)
|
||||
class Solution {
|
||||
public:
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
其直观上来看数组的insert操作是O(n)的,整体代码的时间复杂度是O(n^2)。
|
||||
|
||||
这么一分析好像和版本二链表实现的时间复杂度是一样的啊,为什么提交之后效率会差距这么大呢?
|
||||
```C++
|
||||
```CPP
|
||||
// 版本二,使用list(链表)
|
||||
class Solution {
|
||||
public:
|
||||
@@ -107,7 +107,7 @@ for (int i = 0; i < vec.size(); i++) {
|
||||
|
||||
手动模拟的过程其实不是很简单的,需要很多细节,我粗略写了一个版本,如下:
|
||||
|
||||
```C++
|
||||
```CPP
|
||||
// 版本三
|
||||
// 使用vector,但不让它动态扩容
|
||||
class Solution {
|
||||
|
||||
Reference in New Issue
Block a user