Skip to content
CampusEduX

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.

Related Problems

  • Create and Traverse a Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Insert at Beginning of Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Insert at End of Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...