Easy solution using HashSet
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n        int n=nums.length;\n        if(head==null){\n            return head;\n        }\n\n        HashSet<Integer> hset= new HashSet<>(); // so that we can easily search array elements in O(1)\n        for(int i=0;i<n;i++){\n            hset.add(nums[i]);  // add all elements of array into hset\n        }\n\n\n        ListNode dummy= new ListNode(-1);\n        dummy.next=head;\n        ListNode temp=head;\n        ListNode prev=dummy;\n\n        while(temp!=null){\n            boolean remove=false; // to check wether we want to remove ths node or not\n                if(hset.contains(temp.val)){\n                    remove=true;  // if conditions meets then we want to remove this elemtn as it is in array\n                \n            }\n            if(remove){\n                prev.next=temp.next;\n            }else{\n                prev=prev.next;\n            }\n            temp=temp.next;\n            \n        }\n        return dummy.next;\n\n        \n\n    }\n}\n\n/**\nAnother method without using hashset using loop but it will give TLE in large array cases \n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n \nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n        int n=nums.length;\n        if(head==null){\n            return head;\n        }\n        ListNode dummy= new ListNode(-1);\n        dummy.next=head;\n        ListNode temp=head;\n        ListNode prev=dummy;\n\n        while(temp!=null){\n            boolean remove=false; // to check wether we want to remove ths node or not\n            for(int i=0;i<n;i++){\n                if(nums[i]==temp.val){\n                    remove=true;  // if conditions meets then we want to remove it\n                    break;\n                }\n            }\n            if(remove){\n                prev.next=temp.next;\n            }else{\n                prev=prev.next;\n            }\n            temp=temp.next;\n            \n        }\n        return dummy.next;\n\n        \n\n    }\n} */\n```
['Hash Table', 'Linked List', 'Two Pointers', 'Java']