Delete node in Doubly Linked List
Submissions: 13038   Accuracy:

48.28%

  Difficulty: Basic   Marks: 1

Given a doubly linked list and a position. The task is to delete a node from given position in a doubly linked list.

Input:
First line of input contains number of testcases. First line of each testcase contains number of elements in the linked list and next line contains the elements of the linked list. The last line contains the position from which element is to be deleted.

Output:
Delete the node from the given doubly linked list and set *head_ref if required.

User Task:
The task is to complete the function deleteNode() which should delete the node at given position.

Constraints:
1 <= T <= 300
2 <= N <= 100
1 <= x <= N

Example:
Input:

2
3
1  3 4
3
4
1 5 2 9                    
1

Output:
1 3           
5 2 9

Explanation:
Testcase 1:
After deleting the node at position 3 (position starts from 1), the linked list will be now as 1->3.

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal, Harshit Sidhwa
Author: bhawnamait


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.