203. Remove Linked List Elements
Description
Remove all elements from a linked list of integers that have value val.
Constraints
Approach
Links
GeeksforGeeks
YouTube
Examples
Input: 1->2->6->3->4->5->6, val = 6
Output: 1->2->3->4->5
Solutions
// Definition for singly-linked list.
public class ListNode {
int val;
ListNode next;
ListNode() {}
ListNode(int val) {
this.val = val;
}
ListNode(int val, ListNode next) {
this.val = val;
this.next = next;
}
}
Follow up
Last updated
Was this helpful?