Remove all elements from a linked list of integers that have value val.
Example
Given: 1 -> 2 -> 6 -> 3 -> 4 -> 5 -> 6, val = 6
Return: 1 -> 2 -> 3 -> 4 -> 5
Analysis
To solve this problem, we keep two pointers pre and cur when scanning the LinkedList. Once the current node’s value equals to the target value, we remove the cur node by set pre.next = cur.next;
To make the implementation easier,
[Read More...]










