Delete a Node by Value
Easyjavapythonccppjavascript
Given a singly linked list and a value X, delete the first node containing X. If X is not present, leave the list unchanged.
Input Format
The first line contains an integer N. The second line contains N space-separated integers (empty if N is 0). The third line contains the integer X.
Output Format
Print the updated list from head to tail, separated by single spaces. Print an empty line if the list becomes empty.
Example 1
Input
4 10 20 30 20 20
Output
10 30 20
Explanation: Only the first node containing 20 is removed.
- 0 <= N <= 100000
- -1000000000 <= value, X <= 1000000000