{"id":659,"date":"2025-07-15T13:39:25","date_gmt":"2025-07-15T08:09:25","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=659"},"modified":"2025-07-15T13:39:27","modified_gmt":"2025-07-15T08:09:27","slug":"delete-the-middle-node-of-a-linked-list-leetcode-2095","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/","title":{"rendered":"Delete the Middle Node of a Linked List | Leetcode 2095 | Modified Tortoise and Hare"},"content":{"rendered":"\n<p>You are given the&nbsp;<code>head<\/code>&nbsp;of a linked list.&nbsp;<strong>Delete<\/strong>&nbsp;the&nbsp;<strong>middle node<\/strong>, and return&nbsp;<em>the<\/em>&nbsp;<code>head<\/code>&nbsp;<em>of the modified linked list<\/em>.<\/p>\n\n\n\n<p>The&nbsp;<strong>middle node<\/strong>&nbsp;of a linked list of size&nbsp;<code>n<\/code>&nbsp;is the&nbsp;<code>\u230an \/ 2\u230b<sup>th<\/sup><\/code>&nbsp;node from the&nbsp;<strong>start<\/strong>&nbsp;using&nbsp;<strong>0-based indexing<\/strong>, where&nbsp;<code>\u230ax\u230b<\/code>&nbsp;denotes the largest integer less than or equal to&nbsp;<code>x<\/code>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For&nbsp;<code>n<\/code>&nbsp;=&nbsp;<code>1<\/code>,&nbsp;<code>2<\/code>,&nbsp;<code>3<\/code>,&nbsp;<code>4<\/code>, and&nbsp;<code>5<\/code>, the middle nodes are&nbsp;<code>0<\/code>,&nbsp;<code>1<\/code>,&nbsp;<code>1<\/code>,&nbsp;<code>2<\/code>, and&nbsp;<code>2<\/code>, respectively.<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s the [<strong><a href=\"https:\/\/leetcode.com\/problems\/delete-the-middle-node-of-a-linked-list\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Problem Link<\/span><\/mark><\/a><\/strong>] to begin with.<\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/11\/16\/eg1drawio.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> head = [1,3,4,7,1,2,6]<br><strong>Output:<\/strong> [1,3,4,1,2,6]<br><strong>Explanation:<\/strong><br>The above figure represents the given linked list. The indices of the nodes are written below.<br>Since n = 7, node 3 with value 7 is the middle node, which is marked in red.<br>We return the new list after removing this node. <\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/11\/16\/eg2drawio.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> head = [1,2,3,4]<br><strong>Output:<\/strong> [1,2,4]<br><strong>Explanation:<\/strong><br>The above figure represents the given linked list.<br>For n = 4, node 2 with value 3 is the middle node, which is marked in red.<\/pre>\n\n\n\n<p><strong>Example 3:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/11\/16\/eg3drawio.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> head = [2,1]\n<strong>Output:<\/strong> [2]\n<strong>Explanation:<\/strong>\nThe above figure represents the given linked list.\nFor n = 2, node 1 with value 1 is the middle node, which is marked in red.\nNode 0 with value 2 is the only node remaining after removing node 1.<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The number of nodes in the list is in the range&nbsp;<code>[1, 10<sup>5<\/sup>]<\/code>.<\/li>\n\n\n\n<li><code>1 &lt;= Node.val &lt;= 10<sup>5<\/sup><\/code><\/li>\n<\/ul>\n\n\n<div style=\"max-width: -moz-fit-content; \" class=\"wp-block-ub-table-of-contents-block ub_table-of-contents ub_table-of-contents-collapsed\" id=\"ub_table-of-contents-01f35e55-5e07-4aeb-9fe3-e73fc5cbbf51\" data-linktodivider=\"false\" data-showtext=\"show\" data-hidetext=\"hide\" data-scrolltype=\"auto\" data-enablesmoothscroll=\"true\" data-initiallyhideonmobile=\"true\" data-initiallyshow=\"false\"><div class=\"ub_table-of-contents-header-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-header\" style=\"text-align: left; \">\n\t\t\t\t<div class=\"ub_table-of-contents-title\">Contents:<\/div>\n\t\t\t\t<div class=\"ub_table-of-contents-header-toggle\">\n\t\t\t<div class=\"ub_table-of-contents-toggle\" style=\"\">\n\t\t\t\u00a0[<a class=\"ub_table-of-contents-toggle-link\" href=\"#\" style=\"\">show<\/a>]\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div><div class=\"ub_table-of-contents-extra-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-container ub_table-of-contents-1-column ub-hide\">\n\t\t\t\t<ul style=\"\"><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#0-solution-optimal-approach-modified-tortoise-and-hare\" style=\"\">Solution: Optimal Approach (Modified Tortoise and Hare)<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#1-intuition\" style=\"\">Intuition<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#2-detailed-approach\" style=\"\">Detailed Approach<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#3-code\" style=\"\">Code<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#4-code-explanation\" style=\"\">Code Explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#5-dry-run\" style=\"\">Dry Run<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#6-time-and-space-complexity\" style=\"\">Time and Space Complexity<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#7-simplifying-it\" style=\"\">Simplifying It<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#8-key-insights\" style=\"\">Key Insights<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/delete-the-middle-node-of-a-linked-list-leetcode-2095\/#9-summary\" style=\"\">Summary<\/a><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0-solution-optimal-approach-modified-tortoise-and-hare\">Solution: Optimal Approach (Modified Tortoise and Hare)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-intuition\">Intuition<\/h3>\n\n\n\n<p>Imagine you have two friends running on a track where one runs twice as fast as the other. When the faster friend finishes, the slower friend will be at the middle! But here&#8217;s the twist &#8211; we want to delete the middle node, so we need the slower friend to stop just&nbsp;<strong>before<\/strong>&nbsp;the middle. It&#8217;s like having a security guard positioned right before the middle to &#8220;remove&#8221; the middle person from the line.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-detailed-approach\">Detailed Approach<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Handle Edge Case<\/strong>: If there&#8217;s only one node, return null (delete the only node)<\/li>\n\n\n\n<li><strong>Set Up Two Pointers<\/strong>: Create slow and fast pointers, both starting at head<\/li>\n\n\n\n<li><strong>Give Fast Pointer Head Start<\/strong>: Move fast pointer two steps ahead initially<\/li>\n\n\n\n<li><strong>Move Both Pointers<\/strong>: Move slow 1 step and fast 2 steps until fast reaches the end<\/li>\n\n\n\n<li><strong>Perfect Positioning<\/strong>: When fast reaches the end, slow will be just before the middle node<\/li>\n\n\n\n<li><strong>Delete Middle<\/strong>: Skip the middle node by updating slow&#8217;s next pointer<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-code\">Code<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"class Solution:\n    def deleteMiddle(self, head: Optional[ListNode]) -&gt; Optional[ListNode]:\n        # Handle edge case: single node list\n        if not head.next:\n            return None  # Delete the only node, return empty list\n        \n        slow = head          # Slow pointer (tortoise)\n        fast = head          # Fast pointer (hare)\n        fast = fast.next.next  # Give fast pointer a 2-step head start\n        \n        # Move pointers until fast reaches the end\n        while fast and fast.next:\n            slow = slow.next      # Move slow pointer 1 step\n            fast = fast.next.next # Move fast pointer 2 steps\n        \n        # Delete the middle node by skipping it\n        slow.next = slow.next.next\n        return head\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">Solution<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">deleteMiddle<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">head<\/span><span style=\"color: #D4D4D4\">: Optional[ListNode]) -&gt; Optional[ListNode]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Handle edge case: single node list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> head.next:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">None<\/span><span style=\"color: #D4D4D4\">  <\/span><span style=\"color: #6A9955\"># Delete the only node, return empty list<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        slow = head          <\/span><span style=\"color: #6A9955\"># Slow pointer (tortoise)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        fast = head          <\/span><span style=\"color: #6A9955\"># Fast pointer (hare)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        fast = fast.next.next  <\/span><span style=\"color: #6A9955\"># Give fast pointer a 2-step head start<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Move pointers until fast reaches the end<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">while<\/span><span style=\"color: #D4D4D4\"> fast <\/span><span style=\"color: #569CD6\">and<\/span><span style=\"color: #D4D4D4\"> fast.next:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            slow = slow.next      <\/span><span style=\"color: #6A9955\"># Move slow pointer 1 step<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            fast = fast.next.next <\/span><span style=\"color: #6A9955\"># Move fast pointer 2 steps<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Delete the middle node by skipping it<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        slow.next = slow.next.next<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> head<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">Python<\/span><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-code-explanation\">Code Explanation<\/h3>\n\n\n\n<p>This solution uses a clever modification of the classic tortoise and hare algorithm. Instead of starting both pointers at the same position, we give the fast pointer a two-step head start. This ensures that when the fast pointer reaches the end, the slow pointer is positioned exactly one node before the middle node. This positioning is crucial because we need to access the node before the middle to delete the middle node by updating its next pointer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-dry-run\">Dry Run<\/h3>\n\n\n\n<p>Let&#8217;s trace through:&nbsp;<code>1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt; 5<\/code><\/p>\n\n\n\n<p><strong>Initial Setup:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>slow = 1, fast = 1<\/li>\n\n\n\n<li>Give fast head start: fast = 3<\/li>\n\n\n\n<li>Current state: slow at 1, fast at 3<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 1:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>fast = 5, fast.next = None<\/li>\n\n\n\n<li>slow = 2, fast = 5<\/li>\n\n\n\n<li>Continue (fast exists, fast.next is None)<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 2:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Loop ends because fast.next is None<\/li>\n\n\n\n<li>slow = 2 (positioned before middle node 3)<\/li>\n<\/ul>\n\n\n\n<p><strong>Delete Middle:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>slow.next = 3, slow.next.next = 4<\/li>\n\n\n\n<li>Set slow.next = 4 (skip node 3)<\/li>\n\n\n\n<li>Final result:&nbsp;<code>1 -&gt; 2 -&gt; 4 -&gt; 5<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>Result:<\/strong>&nbsp;Middle node 3 is successfully deleted!<\/p>\n\n\n\n<p>Let&#8217;s also trace a shorter example:&nbsp;<code>1 -&gt; 2 -&gt; 3<\/code><\/p>\n\n\n\n<p><strong>Initial Setup:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>slow = 1, fast = 1<\/li>\n\n\n\n<li>Give fast head start: fast = 3<\/li>\n\n\n\n<li>Current state: slow at 1, fast at 3<\/li>\n<\/ul>\n\n\n\n<p><strong>Check Loop Condition:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>fast = 3 (exists), fast.next = None<\/li>\n\n\n\n<li>Loop doesn&#8217;t execute<\/li>\n<\/ul>\n\n\n\n<p><strong>Delete Middle:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>slow = 1, slow.next = 2<\/li>\n\n\n\n<li>Set slow.next = 2.next (which is 3)<\/li>\n\n\n\n<li>Final result:&nbsp;<code>1 -&gt; 3<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-time-and-space-complexity\">Time and Space Complexity<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Time Complexity:<\/strong>&nbsp;O(n) &#8211; We traverse the list once, visiting each node at most once<\/li>\n\n\n\n<li><strong>Space Complexity:<\/strong>&nbsp;O(1) &#8211; We only use two pointer variables, no extra space needed<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-simplifying-it\">Simplifying It<\/h3>\n\n\n\n<p>This approach is like having a smart assistant who knows exactly where to stand to help you remove the middle person from a line. By giving the fast pointer a head start, we ensure the slow pointer stops at the perfect position &#8211; right before the middle. It&#8217;s an elegant solution that solves the problem in one pass without needing to count the total length first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"8-key-insights\">Key Insights<\/h2>\n\n\n\n<p><strong>Why the head start matters:<\/strong><br>In the classic tortoise and hare algorithm, both pointers start together, and when fast reaches the end, slow is at the middle. But since we want to delete the middle node, we need slow to be&nbsp;<strong>before<\/strong>&nbsp;the middle. The two-step head start achieves this perfectly!<\/p>\n\n\n\n<p><strong>Edge case handling:<\/strong><br>The special check for single-node lists is important because there&#8217;s no &#8220;before middle&#8221; position in a single-node list. We simply return null to indicate an empty list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"9-summary\">Summary<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Approach<\/th><th>Time<\/th><th>Space<\/th><th>Difficulty<\/th><th>Best For<\/th><\/tr><\/thead><tbody><tr><td>Modified Tortoise &amp; Hare<\/td><td>O(n)<\/td><td>O(1)<\/td><td>Medium<\/td><td>Production code<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This&nbsp;<strong>optimal solution<\/strong>&nbsp;efficiently solves the problem in a single pass using constant space. The key insight is the clever modification of the classic two-pointer technique to position the slow pointer exactly where we need it for deletion. This approach demonstrates how small changes to well-known algorithms can solve related problems elegantly!<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/codeanddebug.in\/course\/zero-to-hero-python-dsa\" target=\"_blank\" rel=\"noreferrer noopener\">Join our Advance DSA COURSE<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>For any changes to the article, kindly email at <a href=\"mailto:code@codeanddebug.in\" target=\"_blank\" rel=\"noreferrer noopener\">code@codeanddebug.in<\/a> or contact us at <a href=\"tel:+91-9712928220\" target=\"_blank\" rel=\"noreferrer noopener\">+91-9712928220<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You are given the&nbsp;head&nbsp;of a linked list.&nbsp;Delete&nbsp;the&nbsp;middle node, and return&nbsp;the&nbsp;head&nbsp;of the modified linked list. The&nbsp;middle node&nbsp;of a linked list of size&nbsp;n&nbsp;is the&nbsp;\u230an \/ 2\u230bth&nbsp;node from the&nbsp;start&nbsp;using&nbsp;0-based indexing, where&nbsp;\u230ax\u230b&nbsp;denotes the largest integer less than or equal to&nbsp;x. Here&#8217;s the [Problem Link] to begin with. Example 1: Input: head = [1,3,4,7,1,2,6]Output: [1,3,4,1,2,6]Explanation:The above figure represents the given<\/p>\n","protected":false},"author":1,"featured_media":660,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[19,29],"class_list":{"0":"post-659","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-structures-and-algorithm","8":"category-intermediate","9":"tag-medium","10":"tag-singly-linked-list"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/07\/delete-the-middle-node-of-a-linked-list-featured-image.png","author_info":{"display_name":"codeanddebug","author_link":"https:\/\/codeanddebug.in\/blog\/author\/codeanddebug\/"},"_links":{"self":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":2,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":662,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions\/662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/660"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}