
Delete Alternate Nodes from a Singly Linked List
Given a Singly Linked List of integers, remove all the alternate nodes from the list.
Input:
The first and the only line of input will contain the elements of the Singly Linked List separated by a single space and terminated by -1.
Output:
The only line of output will contain the updated list elements.
Example:
Input: 10 20 30 40 50 60 -1
Output: 10 30 50
Constraints:
1 <= N <= 10^6
where N is the size of the Singly Linked List.- Time Limit: 1 sec
Note:
The head of the list will remain the same. You don't need to print or return anything from your function.

AnswerBot
6d

Remove alternate nodes from a singly linked list of integers.
Traverse the linked list and skip every alternate node while updating the next pointers.
Make sure to handle cases where there are less than...read more

Help your peers!
Add answer anonymously...
Top Amazon Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Amazon Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app