Skip to content

Update 替换空格.py#6

Merged
Jack-Lee-Hiter merged 1 commit intoJack-Lee-Hiter:masterfrom
wangershi:patch-2
Jan 27, 2018
Merged

Update 替换空格.py#6
Jack-Lee-Hiter merged 1 commit intoJack-Lee-Hiter:masterfrom
wangershi:patch-2

Conversation

@wangershi
Copy link
Contributor

replace1方法和replace2方法都是O(n*m)的时间复杂度,这里m是空格的数量,因为list的insert是一个O(n)的复杂度。
而list的append是一个O(1)的时间复杂度,除了扩容时的时间损耗,append方法只需要遍历一次数组即可得结果。

replace1方法和replace2方法都是O(n*m)的时间复杂度,这里m是空格的数量,因为list的insert是一个O(n)的复杂度。
而list的append是一个O(1)的时间复杂度,除了扩容时的时间损耗,append方法只需要遍历一次数组即可得结果。
@Jack-Lee-Hiter Jack-Lee-Hiter merged commit fdb75db into Jack-Lee-Hiter:master Jan 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants