-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7404a9e
commit 083659e
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 </strong>of the linked list. For example, if given linked list is 1->2-><strong>3</strong>->4->5 then linked list should be modified to 1->2->4->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->2->3->4->5->6 then it should be modified to 1->2->3->5->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->2->3->4->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->4->6->7->5->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 return the head of the modified linked list. If the linked list is empty then it should return NULL.</span></p> | ||
|
||
<p><span style="font-size:18px"><strong>Expected Time Complexity: </strong>O(N).<br> | ||
<strong>Expected Auxiliary Space: </strong>O(1).</span></p> | ||
|
||
<p><span style="font-size:18px"><strong>Constraints:</strong><br> | ||
1 <= N <= 1000<br> | ||
1 <= value <= 1000</span></p> | ||
</div> |