1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 11:08:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/链表的中间结点 [middle-of-the-linked-list].html

31 lines
1.0 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给你单链表的头结点 <code>head</code> ,请你找出并返回链表的中间结点。</p>
2022-03-27 20:46:41 +08:00
<p>如果有两个中间结点,则返回第二个中间结点。</p>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:46:41 +08:00
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist1.jpg" style="width: 544px; height: 65px;" />
2022-03-27 20:46:41 +08:00
<pre>
2023-12-09 18:42:21 +08:00
<strong>输入:</strong>head = [1,2,3,4,5]
<strong>输出:</strong>[3,4,5]
<strong>解释:</strong>链表只有一个中间结点,值为 3 。
2022-03-27 20:46:41 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist2.jpg" style="width: 664px; height: 65px;" />
2022-03-27 20:46:41 +08:00
<pre>
2023-12-09 18:42:21 +08:00
<strong>输入:</strong>head = [1,2,3,4,5,6]
<strong>输出:</strong>[4,5,6]
<strong>解释:</strong>该链表有两个中间结点,值分别为 3 和 4 ,返回第二个结点。
2022-03-27 20:46:41 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:46:41 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li>链表的结点数范围是 <code>[1, 100]</code></li>
<li><code>1 &lt;= Node.val &lt;= 100</code></li>
2022-03-27 20:46:41 +08:00
</ul>