mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 08:50:15 +08:00
update 0151.翻转字符串里的单词:添加复杂度分析
This commit is contained in:
@ -114,6 +114,7 @@ void removeExtraSpaces(string& s) {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
有的同学可能发现用erase来移除空格,在leetcode上性能也还行。主要是以下几点;:
|
||||
|
||||
1. leetcode上的测试集里,字符串的长度不够长,如果足够长,性能差距会非常明显。
|
||||
@ -197,6 +198,9 @@ public:
|
||||
};
|
||||
```
|
||||
|
||||
* 时间复杂度: O(n)
|
||||
* 空间复杂度: O(1) 或 O(n),取决于语言中字符串是否可变
|
||||
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
|
Reference in New Issue
Block a user