mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
35 lines
928 B
HTML
35 lines
928 B
HTML
<p>请实现一个函数来判断整数数组 <code>postorder</code> 是否为二叉搜索树的后序遍历结果。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://pic.leetcode.cn/1694762751-fwHhWX-%E5%89%91%E6%8C%8733%E7%A4%BA%E4%BE%8B1.png" /></p>
|
||
|
||
<pre>
|
||
<strong>输入: </strong>postorder = [4,9,6,9,8]
|
||
<strong>输出: </strong>false
|
||
<strong>解释:</strong>从上图可以看出这不是一颗二叉搜索树
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img alt="" src="https://pic.leetcode.cn/1694762510-vVpTic-%E5%89%91%E6%8C%8733.png" /></p>
|
||
|
||
<pre>
|
||
<strong>输入: </strong>postorder = [4,6,5,9,8]
|
||
<strong>输出: </strong>true
|
||
<strong>解释:</strong>可构建的二叉搜索树如上图
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>数组长度 <= 1000</code></li>
|
||
<li><code>postorder</code> 中无重复数字</li>
|
||
</ul>
|
||
|
||
<p> </p>
|