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-di-kda-jie-dian-lcof].html

43 lines
970 B
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<p>某公司组织架构以二叉搜索树形式记录,节点值为处于该职位的员工编号。请返回第 <code>cnt</code> 大的员工编号。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://pic.leetcode.cn/1695101634-kzHKZW-image.png" style="height: 281px; width: 500px;" /></p>
<pre>
<strong>输入:</strong>root = [7, 3, 9, 1, 5], cnt = 2
7
/ \
3 9
/ \
1 5
<strong>输出:</strong>7
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://pic.leetcode.cn/1695101636-ESZtLa-image.png" style="height: 281px; width: 500px;" /></p>
<pre>
<strong>输入:</strong> root = [10, 5, 15, 2, 7, null, 20, 1, null, 6, 8], cnt = 4
10
/ \
5 15
/ \ \
2 7 20
/ / \
1 6 8
<strong>输出:</strong> 8</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>1 ≤ cnt&nbsp;≤ 二叉搜索树元素个数</li>
</ul>
<p>&nbsp;</p>