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)/从链表中移除节点 [remove-nodes-from-linked-list].html

38 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个链表的头节点 <code>head</code></p>
<p>移除每个右侧有一个更大数值的节点。</p>
<p>返回修改后链表的头节点<em> </em><code>head</code><em> </em></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/10/02/drawio.png" style="width: 631px; height: 51px;" /></p>
<pre>
<strong>输入:</strong>head = [5,2,13,3,8]
<strong>输出:</strong>[13,8]
<strong>解释:</strong>需要移除的节点是 5 2 和 3 。
- 节点 13 在节点 5 右侧。
- 节点 13 在节点 2 右侧。
- 节点 8 在节点 3 右侧。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>head = [1,1,1,1]
<strong>输出:</strong>[1,1,1,1]
<strong>解释:</strong>每个节点的值都是 1 ,所以没有需要移除的节点。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>给定列表中的节点数目在范围 <code>[1, 10<sup>5</sup>]</code></li>
<li><code>1 &lt;= Node.val &lt;= 10<sup>5</sup></code></li>
</ul>