Skip to content
C

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.

Input (stdin)

Output

Run your code to see output here...