mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-19 15:53:46 +00:00
Update 9. 用两个栈实现队列.md
图片宽度补上单位。
This commit is contained in:
@@ -14,7 +14,7 @@ in 栈用来处理入栈(push)操作,out 栈用来处理出栈(pop)操
|
||||
|
||||
需要注意的是,只有 out 栈为空时才把 in 栈的元素全部倒进去;out 栈中还有元素时倒入,新元素会压在旧元素上面,先出栈,顺序就乱了。每个元素最多进出 in 栈、out 栈各一次,因此 deleteHead 的均摊时间复杂度为 O(1)。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/3ea280b5-be7d-471b-ac76-ff020384357c.gif" width="450"/> </div><br>
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/3ea280b5-be7d-471b-ac76-ff020384357c.gif" width="450px"/> </div><br>
|
||||
|
||||
```java
|
||||
class CQueue {
|
||||
|
||||
Reference in New Issue
Block a user