mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
36 lines
573 B
HTML
36 lines
573 B
HTML
<p>给定一棵二叉搜索树,请找出其中第 <code>k</code> 大的节点的值。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> root = [3,1,4,null,2], k = 1
|
|
3
|
|
/ \
|
|
1 4
|
|
\
|
|
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> </p>
|
|
|
|
<p><strong>限制:</strong></p>
|
|
|
|
<ul>
|
|
<li>1 ≤ k ≤ 二叉搜索树元素个数</li>
|
|
</ul>
|