mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part2
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<p>输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如,序列 {1,2,3,4,5} 是某栈的压栈序列,序列 {4,5,3,2,1} 是该压栈序列对应的一个弹出序列,但 {4,3,5,1,2} 就不可能是该压栈序列的弹出序列。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
|
||||
<strong>输出:</strong>true
|
||||
<strong>解释:</strong>我们可以按以下顺序执行:
|
||||
push(1), push(2), push(3), push(4), pop() -> 4,
|
||||
push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>pushed = [1,2,3,4,5], popped = [4,3,5,1,2]
|
||||
<strong>输出:</strong>false
|
||||
<strong>解释:</strong>1 不能在 2 之前弹出。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ol>
|
||||
<li><code>0 <= pushed.length == popped.length <= 1000</code></li>
|
||||
<li><code>0 <= pushed[i], popped[i] < 1000</code></li>
|
||||
<li><code>pushed</code> 是 <code>popped</code> 的排列。</li>
|
||||
</ol>
|
||||
|
||||
<p>注意:本题与主站 946 题相同:<a href="https://leetcode-cn.com/problems/validate-stack-sequences/">https://leetcode-cn.com/problems/validate-stack-sequences/</a></p>
|
Reference in New Issue
Block a user