Skip to content

Commit

Permalink
Create README - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
prernagupta2625 committed Mar 29, 2023
1 parent 7404a9e commit 083659e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Delete Middle of Linked List - GFG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Delete Middle of Linked List
## Easy
<div class="problems_problem_content__Xm_eO"><p><span style="font-size:18px">Given a singly linked list, delete <strong>middle&nbsp;</strong>of the linked list. For example, if given linked list is 1-&gt;2-&gt;<strong>3</strong>-&gt;4-&gt;5 then linked list should be modified to 1-&gt;2-&gt;4-&gt;5.<br>
If there are <strong>even</strong> nodes, then there would be <strong>two middle </strong>nodes, we need to delete the second middle element. For example, if given linked list is 1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;6 then it should be modified to 1-&gt;2-&gt;3-&gt;5-&gt;6.</span><br>
<span style="font-size:18px">If the input linked list is NULL or has 1 node, then it should return NULL</span></p>

<p><span style="font-size:18px"><strong>Example 1:</strong></span></p>

<pre><span style="font-size:18px"><strong>Input:
</strong>LinkedList: 1-&gt;2-&gt;3-&gt;4-&gt;5
<strong>Output: </strong>1 2 4 5</span>
</pre>

<p><span style="font-size:18px"><strong>Example 2:</strong></span></p>

<pre><span style="font-size:18px"><strong>Input:
</strong>LinkedList: 2-&gt;4-&gt;6-&gt;7-&gt;5-&gt;1
<strong>Output: </strong>2 4 6 5 1</span></pre>

<p><span style="font-size:18px"><strong>Your Task:</strong><br>
The task is to complete the function <strong>deleteMid</strong>() which should delete the middle element from the linked list and&nbsp;return the head&nbsp;of the modified linked list.&nbsp;If the linked list is empty then it should return NULL.</span></p>

<p><span style="font-size:18px"><strong>Expected Time Complexity:&nbsp;</strong>O(N).<br>
<strong>Expected Auxiliary Space:&nbsp;</strong>O(1).</span></p>

<p><span style="font-size:18px"><strong>Constraints:</strong><br>
1 &lt;= N &lt;= 1000<br>
1 &lt;= value &lt;= 1000</span></p>
</div>

0 comments on commit 083659e

Please sign in to comment.