C#
Code
# Code
```csharp []
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     public int val;
 *     public ListNode next;
 *     public ListNode(int val=0, ListNode next=null) {
 *         this.val = val;
 *         this.next = next;
 *     }
 * }
 */
public class Solution {
    public ListNode ModifiedList(int[] nums, ListNode head) {
         var set = new HashSet<int>(nums);
 var dummy = new ListNode(0, head);
 var cur = dummy;

 while (cur.next != null)
 {
     if (set.Contains(cur.next.val))
     {
         cur.next = cur.next.next;
     }
     else
     {
         cur = cur.next;
     }
 }

 return dummy.next;
    }
}
```
['C#']