1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-26 02:00:27 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/验证二叉搜索树的后序遍历序列 [er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof].html

35 lines
928 B
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<p>请实现一个函数来判断整数数组 <code>postorder</code> 是否为二叉搜索树的后序遍历结果。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>数组长度 &lt;= 1000</code></li>
<li><code>postorder</code> 中无重复数字</li>
</ul>
<p>&nbsp;</p>