203. Remove Linked List Elements
https://leetcode.com/problems/remove-linked-list-elements/
Intuition
Have a prev pointer
If head.val == target
Set the prev to head.next
else
prev = prev.next
Preprocess
Corner case, while head.val == target at the beginning of list
--
Related problems
237-delete-node-in-linked-list
---
Remove all elements from a linked list of integers that have value val.
Example:
Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5--
Intuition
Have a prev pointer
If head.val == target
Set the prev to head.next
else
prev = prev.next
Preprocess
Corner case, while head.val == target at the beginning of list
--
Related problems
237-delete-node-in-linked-list
---