Question
Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.
https://leetcode.com/problems/remove-linked-list-elements/
- Solution1
1 | class Solution { |
Complexity:
Time complexity: O(n)
Space complexity: O(1)