mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			583 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			583 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>设计一个算法,找出二叉搜索树中指定节点的“下一个”节点(也即中序后继)。</p>
 | 
						|
 | 
						|
<p>如果指定节点没有对应的“下一个”节点,则返回<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>
 |