| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10948 | Delete linked list test |
|
Description
This problem will give you a sequence of positive integers. Use this sequence to create a linked list to store those integers. Next, the problem will give you another sequence of positive integers, p0, p1,…pk-1. Delete the nodes that the data is equal to one of p0, p1, …pk-1 of the linked list, where 1<=p0<p1<…pk-1<=N. If the node is not existing,do nothing. And show the final results.

The framework of the program is provided.
- Create a linked list from the input (createList)
- while there are still some data pi
- read in pi
- delete node that data is equal to pi (deleteNode)
- print the remaining list (printList)
- free the list (freeList)
You will be provided with main.c and function.h. main.c contains the implementation of function printList, and freeList, and function.h contains the definition of node and the interface of createList() and deleteNode(&head, pi). You only need to implement createList() and deleteNode(&head, pi) in function.c, in which head is the head of the linked list, and pi is the data of the node to be deleted.
For OJ submission, you only need to submit your createList and deleteNode implementation to the submission block. (Choose c compiler)
Below is the partial code for main.c
main.c
function.h
Input
The input contains 2 sequences of positive integers. The first sequence is to create a linked list of integers, and the second sequence is the nodes to be deleted. Each sequence is ended by -1.
Output
The output contains the sequence of resulting linklist.