1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/算法题(国内版)/problem (Chinese)/二叉搜索树的第k大节点 [er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof].html

36 lines
573 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给定一棵二叉搜索树,请找出其中第 <code>k</code> 大的节点的值。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong> root = [3,1,4,null,2], k = 1
3
/ \
1 4
\
&nbsp; 2
<strong>输出:</strong> 4</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> root = [5,3,6,2,4,null,null,1], k = 3
5
/ \
3 6
/ \
2 4
/
1
<strong>输出:</strong> 4</pre>
<p>&nbsp;</p>
<p><strong>限制:</strong></p>
<ul>
<li>1 ≤ k ≤ 二叉搜索树元素个数</li>
</ul>