Problem
Remove all elements from a linked list of integers that have value val.
Example
1 | Input: 1->2->6->3->4->5->6, val = 6 |
Solution 1
Method:
Time Complexity: O(n)
Space Complexity: O(1)
1 | # Definition for singly-linked list. |
Solution 2
Method: Recursive
Time Complexity:
Space Complexity:
1 | # Definition for singly-linked list. |