1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/后继者 [successor-lcci].html
2022-03-29 12:43:11 +08:00

28 lines
583 B
HTML

<p>设计一个算法,找出二叉搜索树中指定节点的&ldquo;下一个&rdquo;节点(也即中序后继)。</p>
<p>如果指定节点没有对应的&ldquo;下一个&rdquo;节点,则返回<code>null</code></p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:</strong> root = <code>[2,1,3], p = 1
2
/ \
1 3
</code>
<strong>输出:</strong> 2</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:</strong> root = <code>[5,3,6,2,4,null,null,1], p = 6
5
/ \
3 6
/ \
2 4
/
1
</code>
<strong>输出:</strong> null</pre>