Remove Linked List Elements Problem
Remove Linked List Elements Problem — ExecCode Easy DSA Practice
Solve the Remove Linked List Elements problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.
Examples
Input {"values": [1, 2, 6, 3, 4, 5, 6], "val": 6}; Output 1 2 3 4 5. Input {"values": [1, 2, 3, 4, 5], "val": 6}; Output 1 2 3 4 5. Input {"values": [6, 1, 2, 3, 4, 5], "val": 6}; Output 1 2 3 4 5
Constraints
The number of nodes in the list is in the range [0, 10^4]. 1 <= Node.val <= 50 0 <= val <= 50
Practice Remove Linked List Elements free on ExecCode. Browse DSA problems, topic map, and placement guides.