This challenge is part of a tutorial track by MyCodeSchool and is accompanied by a video lesson.
Delete the node at a given position in a linked list and return a reference to the head node. The head is at position 0. The list may be empty after you delete the node. In that case, return a null value.
After removing the node at position , .
Complete the deleteNode function in the editor below.
deleteNode has the following parameters:
- SinglyLinkedListNode pointer llist: a reference to the head node in the list
- int position: the position of the node to remove
- SinglyLinkedListNode pointer: a reference to the head of the modified list
The first line of input contains an integer , the number of elements in the linked list.
Each of the next lines contains an integer, the node data values in order.
The last line contains an integer, , the position of the node to delete.
- , where is the element of the linked list.
8 20 6 2 19 7 4 15 9 3
20 6 2 7 4 15 9
The original list is . After deleting the node at position , the list is .