Class Solution
java.lang.Object
g2001_2100.s2095_delete_the_middle_node_of_a_linked_list.Solution
2095 - Delete the Middle Node of a Linked List.<p>Medium</p>
<p>You are given the <code>head</code> of a linked list. <strong>Delete</strong> the <strong>middle node</strong> , and return <em>the</em> <code>head</code> <em>of the modified linked list</em>.</p>
<p>The <strong>middle node</strong> of a linked list of size <code>n</code> is the <code>\u230an / 2\u230b<sup>th</sup></code> node from the <strong>start</strong> using <strong>0-based indexing</strong> , where <code>\u230ax\u230b</code> denotes the largest integer less than or equal to <code>x</code>.</p>
<ul>
<li>For <code>n</code> = <code>1</code>, <code>2</code>, <code>3</code>, <code>4</code>, and <code>5</code>, the middle nodes are <code>0</code>, <code>1</code>, <code>1</code>, <code>2</code>, and <code>2</code>, respectively.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/11/16/eg1drawio.png" alt="" /></p>
<p><strong>Input:</strong> head = [1,3,4,7,1,2,6]</p>
<p><strong>Output:</strong> [1,3,4,1,2,6]</p>
<p><strong>Explanation:</strong></p>
<p>The above figure represents the given linked list.</p>
<p>The indices of the nodes are written below. Since n = 7, node 3 with value 7 is the middle node, which is marked in red.</p>
<p>We return the new list after removing this node.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/11/16/eg2drawio.png" alt="" /></p>
<p><strong>Input:</strong> head = [1,2,3,4]</p>
<p><strong>Output:</strong> [1,2,4]</p>
<p><strong>Explanation:</strong></p>
<p>The above figure represents the given linked list.</p>
<p>For n = 4, node 2 with value 3 is the middle node, which is marked in red.</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/11/16/eg3drawio.png" alt="" /></p>
<p><strong>Input:</strong> head = [2,1]</p>
<p><strong>Output:</strong> [2]</p>
<p><strong>Explanation:</strong></p>
<p>The above figure represents the given linked list.</p>
<p>For n = 2, node 1 with value 1 is the middle node, which is marked in red.</p>
<p>Node 0 with value 2 is the only node remaining after removing node 1.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the list is in the range <code>[1, 10<sup>5</sup>]</code>.</li>
<li><code>1 <= Node.val <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
deleteMiddle
-