Given a linked list of length N, where the last node points to the M-th node in the list. Note that when M equals 0, it indicates that the last node points to NULL.
Your task is to get an input T and perform T deletion operations.
For each operation, you need to delete the first node with value V equal to A in the list. If no such node is found in the list, skip this operation.
After completing all operations, output each node's value in the linked list once, starting from the head.
If the linked list is empty, output "EMPTY!!!"
Example Operation 1:
Delete a node with value 2.
Delete a node with value 5.
Example Operation 2:
Delete a node with value 5.
Other Example Operation:
This question is a partial judge.
Please implement functions defined in the header file.
The first line contains two integers N and M, where N represents the length of the linked list, and the last node in the linked list points to the M-th node.
The second line contains N integers Vi , representing the value of the i-th node.
The third line contains one integer T, representing T insertion operations to be performed.
The following T lines each contain one integers A, indicating to delete the first node with value V equal to A.
After completing all operations, output each node's value in the linked list once, starting from the head.
If the linked list is empty, output "EMPTY!!!"
Please remember to print "\n" at the end.
You should use the Tortoise and Hare algorithm to pass testcases 6~10.
To complete this problem, the following cases should be taken care of:
To check if you've handled these cases properly, testcases 6~10 are designed in following rules: