Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6454
@blackshadows 6380
@mb1973 5710
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3709
@mantu_singh 3556
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Delete Alternate Nodes
Basic Accuracy: 51.7% Submissions: 32148 Points: 1

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

Example 1:

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

 

Example 2:

Input:
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.

 

Constraints:
1<=N<=100

 

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

to report an issue on this page.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.

Delete Alternate Nodes

Output Window