694. Remove Linked List Elements
0
Easy
Given the head of a linked list and an integer value, remove all nodes from the linked list that have a value equal to the given value, and print the resulting linked list.
Input Format
The first line contains two integers, N and k, representing the length of the linked list and the value to be removed, respectively. The second line contains N integers, representing the nodes of the linked list.
Output Format
Print the resulting linked list.
Example
Input
5 6
1 6 4 6 7
Output
1 4 7
Constraints
The number of nodes in the linked list is between 0 and 10,000 inclusive. Each node's value is an integer between 1 and 50 inclusive.
Loading...
View Submissions
Console