Delete Alternate Nodes
Basic Accuracy: 51.7% Submissions: 36945 Points: 1

Given a Singly Linked List of size N, delete all alternate nodes of the list.

Example 1:

LinkedList: 1->2->3->4->5->6
Output: 1->3->5
Explanation: Deleting alternate nodes
results in the linked list with elements


Example 2:

LinkedList: 99->59->42->20
Output: 99->42


Your Task:

Your task is to complete the function deleteAlt() which takes the head of the linked list in the input parameter and modifies the given linked list accordingly.




Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Delete Alternate Nodes

Output Window