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
Source code
Version 1
Idea: Some inputs maybe like 1->1->2->3->null (val=1) or 1->1->1 (val=1), you have to do check to filer these elements at 16-18.
At 20-22 line, I declare a new ListNode, and link to head. At 23-30 line, you should check the next value of head's element whether it'e equal to val, if it is true at 24 line, it will link to after the next element.