Error
|
|
---|---|
@Ibrahim Nash | 6381 |
@blackshadows | 6329 |
@mb1973 | 5388 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@1905439 | 553 |
@terabaap123 | 508 |
@smitadiwedi1991 | 279 |
@DevanandJayakumar | 250 |
@atishagusain | 244 |
@gupta_10 | 226 |
@shubhamkhullar7 | 224 |
@nipun edara | 224 |
@balunagar | 204 |
@sharmachandan487 | 204 |
@arshjit_singh7 | 190 |
Complete Leaderboard |
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).
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes