mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
27 lines
1023 B
HTML
27 lines
1023 B
HTML
|
<p>用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 <code>appendTail</code> 和 <code>deleteHead</code> ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,<code>deleteHead</code> 操作返回 -1 )</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>
|
|||
|
["CQueue","appendTail","deleteHead","deleteHead"]
|
|||
|
[[],[3],[],[]]
|
|||
|
<strong>输出:</strong>[null,null,3,-1]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>
|
|||
|
["CQueue","deleteHead","appendTail","appendTail","deleteHead","deleteHead"]
|
|||
|
[[],[],[5],[2],[],[]]
|
|||
|
<strong>输出:</strong>[null,-1,null,null,5,2]
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= values <= 10000</code></li>
|
|||
|
<li><code>最多会对 appendTail、deleteHead 进行 10000 次调用</code></li>
|
|||
|
</ul>
|