mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
31 lines
1.0 KiB
HTML
31 lines
1.0 KiB
HTML
<p>给你单链表的头结点 <code>head</code> ,请你找出并返回链表的中间结点。</p>
|
||
|
||
<p>如果有两个中间结点,则返回第二个中间结点。</p>
|
||
|
||
<p> </p>
|
||
|
||
<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;" />
|
||
<pre>
|
||
<strong>输入:</strong>head = [1,2,3,4,5]
|
||
<strong>输出:</strong>[3,4,5]
|
||
<strong>解释:</strong>链表只有一个中间结点,值为 3 。
|
||
</pre>
|
||
|
||
<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;" />
|
||
<pre>
|
||
<strong>输入:</strong>head = [1,2,3,4,5,6]
|
||
<strong>输出:</strong>[4,5,6]
|
||
<strong>解释:</strong>该链表有两个中间结点,值分别为 3 和 4 ,返回第二个结点。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li>链表的结点数范围是 <code>[1, 100]</code></li>
|
||
<li><code>1 <= Node.val <= 100</code></li>
|
||
</ul>
|