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
4mo
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...
Amazon Software Developer interview questions & answers
A Software Developer was asked 1mo agoQ. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ. What is HTML?
A Software Developer was asked 1mo agoQ. What is MySQL?
Popular interview questions of Software Developer
A Software Developer was asked 1mo agoQ1. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ2. What is MySQL?
A Software Developer was asked 1mo agoQ3. What is Java?
Top HR questions asked in Amazon Software Developer
A Software Developer was asked 1mo agoQ1. Tell me about a time you had to get to the root cause of a problem
A Software Developer was asked 5mo agoQ2. What are the short-term and long-term goals for the team or organization?
A Software Developer was asked 5mo agoQ3. Why do you want to work at Amazon?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

