Class Solution
java.lang.Object
g0801_0900.s0876_middle_of_the_linked_list.Solution
876 - Middle of the Linked List.<p>Easy</p>
<p>Given the <code>head</code> of a singly linked list, return <em>the middle node of the linked list</em>.</p>
<p>If there are two middle nodes, return <strong>the second middle</strong> node.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist1.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [1,2,3,4,5]</p>
<p><strong>Output:</strong> [3,4,5]</p>
<p><strong>Explanation:</strong> The middle node of the list is node 3.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/07/23/lc-midlist2.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [1,2,3,4,5,6]</p>
<p><strong>Output:</strong> [4,5,6]</p>
<p><strong>Explanation:</strong> Since the list has two middle nodes with values 3 and 4, we return the second one.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the list is in the range <code>[1, 100]</code>.</li>
<li><code>1 <= Node.val <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
middleNode
-