|
| 1 | +<h2><a href="https://leetcode.com/problems/middle-of-the-linked-list">Middle of the Linked List</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Given the <code>head</code> of a singly linked list, return <em>the middle node of the linked list</em>.</p> |
| 2 | + |
| 3 | +<p>If there are two middle nodes, return <strong>the second middle</strong> node.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | +<img alt="" src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist1.jpg" style="width: 544px; height: 65px;" /> |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> head = [1,2,3,4,5] |
| 10 | +<strong>Output:</strong> [3,4,5] |
| 11 | +<strong>Explanation:</strong> The middle node of the list is node 3. |
| 12 | +</pre> |
| 13 | + |
| 14 | +<p><strong class="example">Example 2:</strong></p> |
| 15 | +<img alt="" src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist2.jpg" style="width: 664px; height: 65px;" /> |
| 16 | +<pre> |
| 17 | +<strong>Input:</strong> head = [1,2,3,4,5,6] |
| 18 | +<strong>Output:</strong> [4,5,6] |
| 19 | +<strong>Explanation:</strong> Since the list has two middle nodes with values 3 and 4, we return the second one. |
| 20 | +</pre> |
| 21 | + |
| 22 | +<p> </p> |
| 23 | +<p><strong>Constraints:</strong></p> |
| 24 | + |
| 25 | +<ul> |
| 26 | + <li>The number of nodes in the list is in the range <code>[1, 100]</code>.</li> |
| 27 | + <li><code>1 <= Node.val <= 100</code></li> |
| 28 | +</ul> |
0 commit comments