Class Solution
-
- All Implemented Interfaces:
public final class Solution3217 - Delete Nodes From Linked List Present in Array.
Medium
You are given an array of integers
numsand theheadof a linked list. Return theheadof the modified linked list after removing all nodes from the linked list that have a value that exists innums.Example 1:
Input: nums = 1,2,3, head = 1,2,3,4,5
Output: 4,5
Explanation:
Remove the nodes with values 1, 2, and 3.
Example 2:
Input: nums = 1, head = 1,2,1,2,1,2
Output: 2,2,2
Explanation:
Remove the nodes with value 1.
Example 3:
Input: nums = 5, head = 1,2,3,4
Output: 1,2,3,4
Explanation:
No node has value 5.
Constraints:
<code>1 <= nums.length <= 10<sup>5</sup></code>
<code>1 <= numsi<= 10<sup>5</sup></code>
All elements in
numsare unique.The number of nodes in the given list is in the range <code>1, 10<sup>5</sup></code>.
<code>1 <= Node.val <= 10<sup>5</sup></code>
The input is generated such that there is at least one node in the linked list that has a value not present in
nums.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final ListNodemodifiedList(IntArray nums, ListNode head)-
-
Method Detail
-
modifiedList
final ListNode modifiedList(IntArray nums, ListNode head)
-
-
-
-