| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11877 | List of Christmas gifts (CS2351) |
|
Description
Objective
- Implement a linked list to store Christmas gifts
- Each node stores a gift and its corresponding price
- Price is a integer and ranges from 0 to 999
- Each gift price is unique, two duplicate prices will not exist at the same time
Examples
(hat, 150) -> (candy, 250) -> (book, 300) ok
(hat, 150) -> (candy, 150) -> (book, 300) incorrect
Requirements
You should implement 4 functions below
- InsertBack(gift, price)
- InsertAfter(gift, price, priceToInsertAfter)
- Delete(price)
- Reverse()
InsertBack(gift, price)
Insert a (gift,price) to the end of the linked list
InsertAfter(gift, price, priceToInsertAfter)
Insert (gift,price) after priceToInsertAfter
If price does not exist in the linked list, do nothing
Delete(price)
Remove the (gift,price) matched price from the linked list
If this price does not exist in the linked list, do nothing
Reverse()
Reverse the linked list
(there are some examples in HW3 slides)
Input
Input format:

The last line of input is "End", and we only need to print the result when get the "End".
Output
Print:
First line: Empty or List
Second line: List of gifts and their corresponding prices
- Connect with symbols "->".
- No space in between.
- If it's Empty, only need to print the first line.
Output format:
