Analysis
- with linked lists, if we are removing something we may need to update head
- value can occur multiple times so we need to remove both
- traversing linked list takes
O(n)
1 | /** |
Next Attempt
1 | /** |
Almost Final Solution
1 | /** |
Final Solution
1 | class Solution { |
Amended Solution
While the above solution is functional, it’s pretty long. We can remove the need for the special case of the val being at the head by using some pointer magic.
TODO: add picture
1 | class Solution { |