mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>请编写一个函数,用于 <strong>删除单链表中某个特定节点</strong> 。在设计函数时需要注意,你无法访问链表的头节点 <code>head</code> ,只能直接访问 <strong>要被删除的节点</strong> 。</p>
 | 
						||
 | 
						||
<p>题目数据保证需要删除的节点 <strong>不是末尾节点</strong> 。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/01/node1.jpg" style="height: 215px; width: 300px;" />
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>head = [4,5,1,9], node = 5
 | 
						||
<strong>输出:</strong>[4,1,9]
 | 
						||
<strong>解释:</strong>指定链表中值为 5 的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -> 1 -> 9
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/01/node2.jpg" style="height: 236px; width: 300px;" />
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>head = [4,5,1,9], node = 1
 | 
						||
<strong>输出:</strong>[4,5,9]
 | 
						||
<strong>解释:</strong>指定链表中值为 1 的第三个节点,那么在调用了你的函数之后,该链表应变为 4 -> 5 -> 9</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li>链表中节点的数目范围是 <code>[2, 1000]</code></li>
 | 
						||
	<li><code>-1000 <= Node.val <= 1000</code></li>
 | 
						||
	<li>链表中每个节点的值都是 <strong>唯一</strong> 的</li>
 | 
						||
	<li>需要删除的节点 <code>node</code> 是 <strong>链表中的节点</strong> ,且 <strong>不是末尾节点</strong></li>
 | 
						||
</ul>
 |