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)/链表的中间结点 [middle-of-the-linked-list].html

31 lines
1.0 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>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>链表的结点数范围是 <code>[1, 100]</code></li>
<li><code>1 &lt;= Node.val &lt;= 100</code></li>
</ul>