1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 19:31:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part2

This commit is contained in:
2022-03-27 20:38:29 +08:00
parent 5a4fa6db12
commit 0fc7f4b734
1617 changed files with 134637 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<p>三合一。描述如何只用一个数组来实现三个栈。</p>
<p>你应该实现<code>push(stackNum, value)</code><code>pop(stackNum)</code><code>isEmpty(stackNum)</code><code>peek(stackNum)</code>方法。<code>stackNum</code>表示栈下标,<code>value</code>表示压入的值。</p>
<p>构造函数会传入一个<code>stackSize</code>参数,代表每个栈的大小。</p>
<p><strong>示例1:</strong></p>
<pre>
<strong> 输入</strong>
["TripleInOne", "push", "push", "pop", "pop", "pop", "isEmpty"]
[[1], [0, 1], [0, 2], [0], [0], [0], [0]]
<strong> 输出</strong>
[null, null, null, 1, -1, -1, true]
<strong>说明</strong>:当栈为空时`pop, peek`返回-1当栈满时`push`不压入元素。
</pre>
<p><strong>示例2:</strong></p>
<pre>
<strong> 输入</strong>
["TripleInOne", "push", "push", "push", "pop", "pop", "pop", "peek"]
[[2], [0, 1], [0, 2], [0, 3], [0], [0], [0], [0]]
<strong> 输出</strong>
[null, null, null, null, 2, 1, -1, -1]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= stackNum &lt;= 2</code></li>
</ul>