mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-11 18:31:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
<p>请编写一个函数,用于 <strong>删除单链表中某个特定节点</strong> 。在设计函数时需要注意,你无法访问链表的头节点 <code>head</code> ,只能直接访问 <strong>要被删除的节点</strong> 。</p>
|
||||
<p>有一个单链表的 <code>head</code>,我们想删除它其中的一个节点 <code>node</code>。</p>
|
||||
|
||||
<p>题目数据保证需要删除的节点 <strong>不是末尾节点</strong> 。</p>
|
||||
<p>给你一个需要删除的节点 <code>node</code> 。你将 <strong>无法访问</strong> 第一个节点 <code>head</code>。</p>
|
||||
|
||||
<p>链表的所有值都是 <b>唯一的</b>,并且保证给定的节点 <code>node</code> 不是链表中的最后一个节点。</p>
|
||||
|
||||
<p>删除给定的节点。注意,删除节点并不是指从内存中删除它。这里的意思是:</p>
|
||||
|
||||
<ul>
|
||||
<li>给定节点的值不应该存在于链表中。</li>
|
||||
<li>链表中的节点数应该减少 1。</li>
|
||||
<li><code>node</code> 前面的所有值顺序相同。</li>
|
||||
<li><code>node</code> 后面的所有值顺序相同。</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>自定义测试:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>对于输入,你应该提供整个链表 <code>head</code> 和要给出的节点 <code>node</code>。<code>node</code> 不应该是链表的最后一个节点,而应该是链表中的一个实际节点。</li>
|
||||
<li>我们将构建链表,并将节点传递给你的函数。</li>
|
||||
<li>输出将是调用你函数后的整个链表。</li>
|
||||
</ul>
|
||||
|
||||
<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;" />
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/01/node1.jpg" style="height: 286px; width: 400px;" />
|
||||
<pre>
|
||||
<strong>输入:</strong>head = [4,5,1,9], node = 5
|
||||
<strong>输出:</strong>[4,1,9]
|
||||
@@ -13,7 +32,7 @@
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/01/node2.jpg" style="height: 236px; width: 300px;" />
|
||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/01/node2.jpg" style="height: 315px; width: 400px;" />
|
||||
<pre>
|
||||
<strong>输入:</strong>head = [4,5,1,9], node = 1
|
||||
<strong>输出:</strong>[4,5,9]
|
||||
|
Reference in New Issue
Block a user