Problem Statement: Delete Node In A Linked List
Given a singly linked list of integers and a reference to a node, your task is to delete that specific node from the linked list. Each node in the linked list has a unique value.
Input:
The first line contains an integer 'T' indicating the number of test cases. For each test case, the first line consists of space-separated integers representing the linked list nodes, ending with -1 (which is not a part of the linked list node values). The second line contains an integer K, the value of the node to be deleted.
Output:
For each test case, after deleting the specified node, print the modified linked list's node values, separated by a single space, followed by '-1' to denote the end of the list. Each result should be printed on a new line.
Example:
Input:
2
4 5 1 9 -1
5
4 5 1 9 -1
1
Output:
4 1 9 -1
4 5 9 -1
Constraints:
- 1 <= T <= 100
- 2 <= N <= 5000
- -109 <= NODE.DATA <= 109 and node.data != -1
Where 'N' denotes the number of nodes in the linked list and 'NODE.DATA' is the value of a node.
Note:
• The reference to the head of the linked list is not provided.
• The node to be deleted is not the tail node.
• Each node's value in the linked list is unique.
• The node to be deleted will always exist in the linked list.

AnswerBot
4mo
Given a singly linked list of integers and a reference to a node, delete the specified node from the linked list.
Traverse the linked list to find the node to be deleted
Update the pointers to skip over...read more
Help your peers!
Add answer anonymously...
UnitedHealth Software Developer interview questions & answers
A Software Developer was asked 7mo agoQ. Explain inheritance and encapsulation in OOPS.
A Software Developer was asked Q. What is the difference between full and partial selectors?
A Software Developer was asked Q. Given a triangle with height h and base length b, and a square of side length a,...read more
Popular interview questions of Software Developer
A Software Developer was asked 7mo agoQ1. Explain inheritance and encapsulation in OOPS.
A Software Developer was asked Q2. What is the difference between full and partial selectors?
A Software Developer was asked Q3. Given a triangle with height h and base length b, and a square of side length a,...read more
>
UnitedHealth Software Developer Interview Questions
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

