parent
77e789a248
commit
55eb649434
|
|
@ -302,7 +302,7 @@ class MyStack:
|
|||
Python普通的Queue或SimpleQueue没有类似于peek的功能
|
||||
也无法用索引访问,在实现top的时候较为困难。
|
||||
|
||||
用list可以,但是在使用pop(0)的时候时间复杂度为O(1)
|
||||
用list可以,但是在使用pop(0)的时候时间复杂度为O(n)
|
||||
因此这里使用双向队列,我们保证只执行popleft()和append(),因为deque可以用索引访问,可以实现和peek相似的功能
|
||||
|
||||
in - 存所有数据
|
||||
|
|
|
|||
Loading…
Reference in New Issue